Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork312
Update test case#42
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
thangtran180492 wants to merge1 commit intorampatra:masterChoose a base branch fromthangtran180492:master
base:master
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
10 changes: 8 additions & 2 deletionssrc/main/java/com/ctci/arraysandstrings/CheckPermutation.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletionssrc/main/java/com/ctci/arraysandstrings/TestCheckPermutation.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package com.ctci.arraysandstrings; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import org.junit.jupiter.api.Test; | ||
class TestCheckPermutation { | ||
@Test | ||
void testPermutationStringWithEmpty() { | ||
String a1 = ""; | ||
String a2 = ""; | ||
String b1 = "1234567890 qwertyuiopasdfghjklzxcvbnm !@#$%^&*()-="; | ||
String b2 = ""; | ||
String c1 = ""; | ||
String c2 = "1234567890 qwertyuiopasdfghjklzxcvbnm !@#$%^&*()-="; | ||
boolean resultA = CheckPermutation.isOnePermutationOfOther(a1, a2); | ||
boolean resultB = CheckPermutation.isOnePermutationOfOther(b1, b2); | ||
boolean resultC = CheckPermutation.isOnePermutationOfOther(c1, c2); | ||
assertTrue(resultA); | ||
assertFalse(resultB); | ||
assertFalse(resultC); | ||
} | ||
@Test | ||
void testPermutationStringAllCharacter() { | ||
String a1 = "1234567890 qwertyuiopasdfghjklzxcvbnm QWERTYUIOPASDFGHJKLZXCVBNM !@#$%^&*()-="; | ||
String a2 = "!@#$%^&*()-= 1234567890 qwertyuiopasdfghjklzxcvbnm QWERTYUIOPASDFGHJKLZXCVBNM"; | ||
String b1 = "~!@#$%^&*([{<>}])+-=:;'\\\",./? "; | ||
String b2 = " ?/.,\"\\';:=-+)}]><[{(*&^%$#@!~"; | ||
String c1 = "Â Ă Ơ Ô Ư Ê â ă ơ ô ư ê"; | ||
String c2 = "ê ư ô ơ ă â Ê Ư Ô Ơ Ă Â"; | ||
String d1 = "ÂÂ ĂĂ ƠƠ ÔÔ ƯƯ ÊÊ ââ ăă ơơ ôô ưư êê"; | ||
String d2 = "ê ư ô ơ ă â Ê Ư Ô Ơ Ă Â"; | ||
boolean resultA = CheckPermutation.isOnePermutationOfOther(a1, a2); | ||
boolean resultB = CheckPermutation.isOnePermutationOfOther(b1, b2); | ||
boolean resultC = CheckPermutation.isOnePermutationOfOther(c1, c2); | ||
boolean resultD = CheckPermutation.isOnePermutationOfOther(d1, d2); | ||
assertTrue(resultA); | ||
assertTrue(resultB); | ||
assertTrue(resultC); | ||
assertFalse(resultD); | ||
} | ||
@Test | ||
void testPermutationWithAsciiAndStringEmpty() { | ||
String a1 = ""; | ||
String a2 = ""; | ||
String b1 = "1234567890 qwertyuiopasdfghjklzxcvbnm !@#$%^&*()-="; | ||
String b2 = ""; | ||
String c1 = ""; | ||
String c2 = "1234567890 qwertyuiopasdfghjklzxcvbnm !@#$%^&*()-="; | ||
boolean resultA = CheckPermutation.isOnePermutationOfOtherGivenThatStringsContainOnlyAscii(a1, a2); | ||
boolean resultB = CheckPermutation.isOnePermutationOfOtherGivenThatStringsContainOnlyAscii(b1, b2); | ||
boolean resultC = CheckPermutation.isOnePermutationOfOtherGivenThatStringsContainOnlyAscii(c1, c2); | ||
assertTrue(resultA); | ||
assertFalse(resultB); | ||
assertFalse(resultC); | ||
} | ||
@Test | ||
void testPermutationWithAsciiAndStringAllCharacter() { | ||
String a1 = "1234567890 qwertyuiopasdfghjklzxcvbnm QWERTYUIOPASDFGHJKLZXCVBNM !@#$%^&*()-="; | ||
String a2 = "!@#$%^&*()-= 1234567890 qwertyuiopasdfghjklzxcvbnm QWERTYUIOPASDFGHJKLZXCVBNM"; | ||
String b1 = "~!@#$%^&*([{<>}])+-=:;'\\\",./? "; | ||
String b2 = " ?/.,\"\\';:=-+)}]><[{(*&^%$#@!~"; | ||
String c1 = "Â Ă Ơ Ô Ư Ê â ă ơ ô ư ê"; | ||
String c2 = "ê ư ô ơ ă â Ê Ư Ô Ơ Ă Â"; | ||
String d1 = "Â Ă Ơ Ô Ư Ê â ă ơ ô ư ê"; | ||
String e2 = "ê ư ô ơ ă â Ê Ư Ô Ơ Ă Â"; | ||
boolean resultA = CheckPermutation.isOnePermutationOfOtherGivenThatStringsContainOnlyAscii(a1, a2); | ||
boolean resultB = CheckPermutation.isOnePermutationOfOtherGivenThatStringsContainOnlyAscii(b1, b2); | ||
boolean resultC = CheckPermutation.isOnePermutationOfOtherGivenThatStringsContainOnlyAscii(c1, c2); | ||
assertTrue(resultA); | ||
assertTrue(resultB); | ||
assertFalse(resultC); | ||
} | ||
} |
50 changes: 50 additions & 0 deletionssrc/main/java/com/hackerrank/algorithms/strings/TestMakingAnagrams.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.hackerrank.algorithms.strings; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import org.junit.jupiter.api.Test; | ||
class TestMakingAnagrams { | ||
@Test | ||
void testWithStringEmpty() { | ||
String a1 = ""; | ||
String a2 = ""; | ||
int resultA = 0; | ||
int countA = MakingAnagrams.makeAnagrams(a1, a2); | ||
assertEquals(countA, resultA); | ||
String b1 = ""; | ||
String b2 = "1234567890qwertyuiop"; | ||
int resultB = 20; | ||
int countB = MakingAnagrams.makeAnagrams(b1, b2); | ||
assertEquals(countB, resultB); | ||
} | ||
@Test | ||
void testWithStringAllCharacter() { | ||
String a1 = "1234567890 ~!@#$%^"; | ||
String a2 = "&*()-+1234567890 "; | ||
int resultA = 13; | ||
int countA = MakingAnagrams.makeAnagrams(a1, a2); | ||
assertEquals(countA, resultA); | ||
String b1 = "asdfghjklb1234567890 "; | ||
String b2 = "1234567890 qwertyuiop"; | ||
int resultB = 20; | ||
int countB = MakingAnagrams.makeAnagrams(b1, b2); | ||
assertEquals(countB, resultB); | ||
String c1 = "hello my world"; | ||
String c2 = "this is my world"; | ||
int resultC = 10; | ||
int countC = MakingAnagrams.makeAnagrams(c1, c2); | ||
assertEquals(countC, resultC); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.