Created
March 19, 2010 11:30
-
-
Save bassemZohdy/337433 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//"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