Trigger Words to Pattern Mapping Flashcards

(14 cards)

1
Q

What are the trigger words associated with substring/subarray problems?

A
  • substring
  • subarray
  • contiguous

These words indicate the need to find contiguous sequences within a data structure.

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

What pattern is commonly used for substring/subarray problems?

A

Sliding Window

This pattern helps in efficiently managing the current window of elements being considered.

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

What data structures are used for finding duplicates/repeating?

A
  • Set (for uniqueness)
  • HashMap (for counting)

Sets allow for O(1) lookup to check for existing elements.

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

What are the trigger words for sum problems?

A
  • two sum
  • three sum
  • pair that sums

These phrases indicate the need to find pairs or groups of numbers that sum to a specific target.

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

What pattern is used for valid/balanced problems?

A

Stack

The stack’s LIFO structure is suitable for matching opening and closing elements.

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

What are the trigger words for counting/frequency problems?

A
  • count frequency
  • most frequent
  • group by

These phrases indicate the need to analyze the frequency of elements.

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

What data structure is commonly used for counting/frequency problems?

A
  • HashMap
  • Counter

The defaultdict or Counter from collections can simplify counting tasks.

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

What are the trigger words for interval problems?

A
  • intervals
  • merge
  • overlap

These words indicate the need to manage and manipulate ranges of values.

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

What pattern is used for tree level/layer problems?

A

BFS

Breadth-First Search is effective for exploring tree levels.

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

What approach is commonly used for tree path problems?

A

Recursion

This approach allows for depth-first traversal of tree paths.

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

What are the trigger words for all combinations/permutations?

A
  • all combinations
  • all permutations
  • all possible ways

These phrases indicate the need to generate all possible arrangements of elements.

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

What pattern is used for finding in sorted arrays?

A

Binary Search

This pattern employs a divide and conquer strategy to efficiently locate elements.

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

What are the trigger words for top K/Kth largest problems?

A
  • top K
  • Kth largest
  • Kth smallest

These phrases indicate the need to find specific ranked elements within a dataset.

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

What pattern is used for maximum/minimum subarray problems?

A

Kadane’s Algorithm or Sliding Window

These methods help in efficiently calculating maximum or minimum sums of contiguous subarrays.

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