Arrays n Hashing Flashcards

1
Q

Find two repeated

A

The trick here is to modify the current array by using element as index in range 0 to n-1 and multiply by -1 to keep track of element. Use arr[abs(arr[i])] *= -1

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

Hashing for pair-2 sum

A

In case of distinct elements, we can just use a set. In case duplicates are present, store count of elements in the map.

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