Array Techniques Flashcards

1
Q

Technique 1

A

Sliding window

the two pointers usually move in the same direction will never overtake

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

Technique 2

A

Two pointers

two pointers is a more general version of sliding window where the point

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

Technique 4

A

Sorting the array

s the array sorted or partially sorted? If it is, some form of binary se

**Sometimes sorting the array first may significantly simplify the problem. Obviously this would not work if the order of array elements need to be preserved. **

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

Technique 3

A

Traversing from the right

Sometimes you can traverse the array starting from the right instead of

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

Technique 5

A

Precomputation

For questions where summation or multiplication of a subarray is involve

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

Technique 6

A

Index as a hash key

If you are given a sequence and the interviewer asks for O(1) space, it

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

Technique 7

A

Traversing the array more than once

This might be obvious, but traversing the array twice/thrice (as long as

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