Skip to content

Commit 24b17b5

Browse files
committed
Updated 2 solutions
1 parent 64d0950 commit 24b17b5

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed
Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
/** Tips **/
2-
3-
// Should ask interviewer if String is ASCII or Unicode (We assume ASCII)
4-
5-
/** Algorithm **/
6-
7-
// Use a HashMap to store characters and detect duplicates.
8-
9-
/** Solution **/
10-
111
package _1_1_Is_Unique;
122

133
import java.util.HashSet;
144

5+
// Should ask interviewer if String is ASCII or Unicode (We assume ASCII)
6+
157
public class IsUnique {
168
private static final int NUM_CHARS = 256; // number of ASCII characters
179

@@ -31,17 +23,10 @@ public static boolean uniqueCharacters(String str) {
3123
}
3224
}
3325

34-
/** Time/Space Complexity **/
35-
3626
// Time Complexity: O(1)
3727
// Space Complexity: O(1)
3828
// Checking for str.length() > 256 lowered our time/space complexity from O(n) to O(1)
3929

40-
/** Follow-up Question **/
41-
42-
// What if we're not allowed to use additional data structures?
43-
44-
/** Follow-up Answer **/
45-
46-
// Do a brute-force solution using nested loops to compare all pairs.
47-
// This will be O(n^2) time complexity and O(1) space complexity.
30+
// Follow-up Question: What if we're not allowed to use additional data structures?
31+
//
32+
// Answer: Can do brute-force O(n^2) runtime O(1) space solution by comparing all pairs

Chp. 01 - Arrays and Strings/_1_4_Palindrome_Permutation/PalindromePermutation.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
public class PalindromePermutation {
66
public static boolean palPerm(String str) {
7-
/* Create HashMap to count characters in String */
87
str = str.toLowerCase().replaceAll("\\s", "");
98
HashMap<Character, Integer> map = new HashMap<>(26);
109
for (int i = 0; i < str.length(); i++) {

0 commit comments

Comments
 (0)