OA exam Flashcards
1
Q
a hashset contains….
a hashmap contains…
a treemap contains…
A
hashset. contains(item) –> O(1) (because under is hashmap)
hashmap. containsKey(key) –>O(1)
treemap. containsKey(key) –>O(nlogn)
2
Q
sort a String str characters
A
char[] charArray = str.toCharArray(); Arrays.sort(charArray); sortedStr = new String(charArray);
note: char charArray[] is also valid