is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
import java.util.Scanner;
- ABHISEK October 10, 2015public class SplitTheString {
class SplitTheStringException extends Exception{
public SplitTheStringException(String str){
super(str);
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
String inputString = null;
String inputPattern = null;
String inputPatternWithoutSpace = null;
String separator = null;
char [] arrPattern = null;
@SuppressWarnings("resource")
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the String : ");
inputString = scanner.nextLine();
System.out.println("Enter the pattern : ");
inputPattern = scanner.nextLine();
inputPatternWithoutSpace = inputPattern.replaceAll("\\s", "");
arrPattern = inputPatternWithoutSpace.toCharArray();
System.out.println("Enter the separator: ");
separator = scanner.nextLine();
try{
System.out.println("Result : " +stringSeparator(inputString, arrPattern, separator));
}catch(Exception e){
e.printStackTrace();
}
}
public static String stringSeparator(String str, char[] arr, String separator) throws Exception{
StringBuilder strBuilder = new StringBuilder();
int startPosition = 0;
for(int i =0; i<arr.length; i++){
int endPosition = startPosition + Character.getNumericValue(arr[i]);
if(startPosition <= str.length() && endPosition <= str.length()){
strBuilder.append(str.substring(startPosition, endPosition));
if(i != arr.length-1)
strBuilder.append(separator);
startPosition = endPosition;
}else throw new SplitTheString().new SplitTheStringException("Invalid Pattern");
}
return strBuilder.toString();
}
}