/ Published in: Java
Expand |
Embed | Plain Text
//"abc" "bc" -> [ 0 ] //"abc" "c" -> [ 0, 1 ] //"abac" -> "aac" -> [ 1 ] //"aabc" -> "abc" -> [ 0 ] *or* [ 1 ] 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; }
You need to login to post a comment.
