Skip to content

Instantly share code, notes, and snippets.

@bassemZohdy
Created March 19, 2010 11:30
Show Gist options
  • Save bassemZohdy/337433 to your computer and use it in GitHub Desktop.
Save bassemZohdy/337433 to your computer and use it in GitHub Desktop.
//"abc" "bc" -> [ 0 ]
//"abc" "c" -> [ 0, 1 ]
//"abac" -> "aac" -> [ 1 ]
//"aabc" -> "abc" -> [ 0 ] *or* [ 1 ]
public static List getDeletedChar(String a, String b) {
List results = new ArrayList();
int charIndex;
int cursorPos = 0;
for (int i = 0; i < b.length(); i++) {
charIndex = a.indexOf(b.charAt(i), cursorPos);
for (int j = cursorPos; j < charIndex; j++) {
results.add(j);
}
cursorPos = charIndex + 1;
}
while(cursorPos < a.length()){
results.add(cursorPos++);
}
return results;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment