Skip to content

Commit

Permalink
Fix careercup#218 Arrays and Strings: One away when string are same
Browse files Browse the repository at this point in the history
  • Loading branch information
vbhosle committed Apr 30, 2021
1 parent 59018cf commit bb51abf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Expand Up @@ -13,7 +13,7 @@ public static boolean oneEditReplace(String s1, String s2) {
foundDifference = true;
}
}
return true;
return foundDifference;
}

/* Check if you can insert a character into s1 to make s2. */
Expand Down
Expand Up @@ -27,7 +27,7 @@ public static boolean oneEditAway(String first, String second) {
}
index2++; // Always move pointer for longer string
}
return true;
return foundDifference || (index1 < s1.length() || index2 < s2.length());
}


Expand Down
3 changes: 2 additions & 1 deletion Java/Ch 01. Arrays and Strings/Q1_05_One_Away/Tester.java
Expand Up @@ -26,7 +26,8 @@ public static void main(String[] args) {
{"adfdsfadsf", "bdfdsfadsg", "false"},
{"adfdsfadsf", "affdsfads", "false"},
{"pale", "pkle", "true"},
{"pkle", "pable", "false"}};
{"pkle", "pable", "false"},
{"pale", "pale", "false"}};
for (int i = 0; i < tests.length; i++) {
String[] test = tests[i];
String a = test[0];
Expand Down

0 comments on commit bb51abf

Please sign in to comment.