Park
BAN USER
Comments (4)
Reputation 50
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
3
of 3 vote
I change a little bit in your method checkSeq(), so it can check case like:"1310213102a"
public static boolean checkSeq(String pw) {
for (int i = 0; i < pw.length(); i++) {
char c1 = pw.charAt(i);
int nextIndex = pw.indexOf(c1, i + 1);
while (nextIndex != -1) {
String s1 = pw.substring(i, nextIndex);
if (2 * nextIndex - i <= pw.length()) {
String s2 = pw.substring(nextIndex, 2 * nextIndex - i);
if (s1.equals(s2)) {
return false;
}
}
nextIndex = pw.indexOf(c1, nextIndex + 1);
}
}
return true;
}
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
In the question, "can't" will be separated to "ca n't", but it seems like your code doesn't do that.
- Park April 06, 2014