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 57951c3
Show file tree
Hide file tree
Showing 9 changed files with 283 additions and 3 deletions.
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

230 changes: 230 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions CtCIv6.iml
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/bin" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/Java/Introduction" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/Java/Big O" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/Java/Ch 01. Arrays and Strings" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/Java/Ch 02. Linked Lists" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/Java/Ch 03. Stacks and Queues" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/Java/Ch 04. Trees and Graphs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/Java/Ch 05. Bit Manipulation" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/Java/Ch 06. Math and Logic Puzzles" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/Java/Ch 07. Object-Oriented Design" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/Java/Ch 08. Recursion and Dynamic Programming" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/Java/Ch 09. Scalability and Memory Limits" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/Java/Ch 10. Sorting and Searching" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/Java/Ch 13. Java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/Java/Ch 16. Moderate" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/Java/Ch 15. Threads and Locks" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/Java/Ch 17. Hard" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/Java/CtCILibrary" isTestSource="false" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="inheritedJdk" />
</component>
</module>
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 57951c3

Please sign in to comment.