int p1 = 0;
int p2 = 1;
boolean isSegment = false;
while(p2 != inputString.length()) {
String sub = inputString.substring(p1, p2+1);
if(dictionary.contains(sub)) {
isSegment = true;
p1 = p2 + 1;
p2++;
}
else {
isSegment = false;
p2++;
}
}
return isSegment;`
Course: https://www.educative.io/courses/coderust-hacking-the-coding-interview
Lesson: Word Break Problem - Coderust: Hacking the Coding Interview