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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly