Core Pattern Recognition Framework Flashcards

Patter ID Decision Tree (6 cards)

1
Q

Do I need to track what I’ve seen?

A

YES → Use HashMap (if need counts/values) or Set (if just checking presence) Examples: Two Sum, Longest Substring Without Repeating Characters

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

Do I need to maintain order and remove from both ends?

A

YES → Use Deque Examples: Sliding window maximum, BFS traversal

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

Do I need to match or validate pairs?

A

YES → Use Stack Examples: Valid Parentheses, Daily Temperatures

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

Am I working with a contiguous subarray or substring?

A

YES → Use Sliding Window pattern (often with Set or HashMap) Examples: Maximum sum subarray, substring problems

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

Do I need the smallest or largest elements repeatedly?

A

YES → Use Heap Examples: Top K elements, Kth largest element

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

Is the input sorted or can I sort it?

A

YES → Use Two Pointers Examples: Two Sum II, Container with Most Water

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