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.*;
- theajr November 13, 2017class StringSegmentation {
static String[] getSegments(String string, int segmentLength) {
ArrayList < String > ls = new ArrayList < String > ();
int startIndex = 0;
int count = 1;
int length = string.length();
int additionalLength = 0;
while (startIndex < length) {
if (count < 10) {
additionalLength = 6;
} else if (count < 100) {
additionalLength = 7;
}
int endIndex = startIndex + segmentLength - additionalLength;
String seg;
try {
seg = string.substring(startIndex, endIndex + 1);
} catch (Exception e) {
seg = string.substring(startIndex);
}
System.out.println(seg);
ls.add(seg); // +1 as substring is exclusive
startIndex = endIndex + 1;
System.out.println(startIndex);
count++;
}
String list[] = new String[ls.size()];
list = ls.toArray(list);
System.out.println(Arrays.toString(list));
for (int i = 0; i < list.length; i++) {
String addPart = String.format(" (%d/%d)", (i + 1), list.length);
if (i == list.length - 1) addPart = addPart.trim();
list[i] = list[i] + addPart;
}
return list;
}
public static void main(String[] args) {
String str = "This is a good day";
int k = 10; // segment length
String segments[] = getSegments(str, k);
int segmentsCount = segments.length;
System.out.println(segmentsCount);
System.out.println(Arrays.toString(segments));
}
}