Problem Specific Quick Tips Flashcards

(10 cards)

1
Q

What is the pattern used in the Two Sum problem?

A

HashMap to store complements

Key line: if (target - num) in seen: return [seen[target-num], i]

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

What data structure is used in the Valid Parentheses problem?

A

Stack for matching pairs

Key insight: Push opening brackets, pop and verify closing brackets match

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

What is the key insight for the Best Time to Buy and Sell Stock problem?

A

Track minimum price so far, calculate profit at each point

Key lines: min_price = min(min_price, price); max_profit = max(max_profit, price - min_price)

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

What algorithm is used in the Maximum Subarray problem?

A

Kadane’s algorithm

Key insight: Current sum = max(current number, current sum + current number)

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

What is the pattern used in the Longest Substring Without Repeating problem?

A

Sliding window with set

Key insight: Expand right, shrink left when duplicate found

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

What is the key line for the Merge Intervals problem?

A

if current[0] <= last[1]: merge

Pattern: Sort by start, merge overlapping

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

What is the pattern used in the Product of Array Except Self problem?

A

Prefix and suffix products

Key insight: Result[i] = prefix[i-1] * suffix[i+1]

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

What data structure is used in the Group Anagrams problem?

A

HashMap with sorted string as key

Key line: key = ““.join(sorted(word))

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

What is the pattern used in the Binary Tree Level Order Traversal problem?

A

BFS with queue

Key insight: Process all nodes at current level before moving to next

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

What is the key insight for the Climbing Stairs problem?

A

Dynamic programming (like Fibonacci)

Key insight: ways[i] = ways[i-1] + ways[i-2]

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