Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #218 Arrays and Strings: One away when string are same #219

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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