Lesson 25/25 ยท ๐ฏ Interview Patterns
๐ฏ Interview PatternsLesson 25/25
Phase 9 ยท Interview Patterns30 min
Top Interview Patterns
The 5 pattern recognition skills that unlock 80% of coding interview problems
Here is a secret about coding interviews. The hard part is not writing the code. It is looking at a brand new problem and knowing which tool it wants. Almost every question is an old friend wearing a costume.
And here is the good news: you have already met all the tools. Two pointers, sliding window, hash maps, trees, heaps, dynamic programming, you built each one in this track. This lesson is only about the last skill, spotting which one a problem is quietly asking for. So let's practise exactly that.
And here is the good news: you have already met all the tools. Two pointers, sliding window, hash maps, trees, heaps, dynamic programming, you built each one in this track. This lesson is only about the last skill, spotting which one a problem is quietly asking for. So let's practise exactly that.
How did you spot them? By the words in the problem. Each pattern leaves fingerprints, and once you know them, half the puzzle is already solved before you write a line.
Fast & Slow Pointers, detect cycle in linked listpython
class Node:
def __init__(self, val): self.val = val; self.next = None
def has_cycle(head):
"""Floyd's algorithm: slow moves 1 step, fast moves 2."""
slow = fast = head
while fast and fast.next:
slow = slow.next
fast = fast.next.next
if slow is fast: # They met, there's a cycle
return True
return False # Fast reached end, no cycle
# Build a cycle: 1โ2โ3โ4โ2 (4 points back to 2)
nodes = [Node(i) for i in range(1, 5)]
for i in range(3): nodes[i].next = nodes[i+1]
nodes[3].next = nodes[1] # Cycle
print(has_cycle(nodes[0])) # โ TruePattern Recognition Cheat Sheet:
| You seeโฆ | Thinkโฆ |
|---|---|
| Sorted array + find pair | Two Pointers |
| Subarray/substring of size k | Fixed Sliding Window |
| Longest/shortest subarray with condition | Variable Sliding Window |
| Tree/graph traversal, shortest path | BFS |
| Tree/graph: all paths, cycle detection | DFS |
| "How many ways", "minimum cost" | Dynamic Programming |
| "Linked list cycle", "find middle" | Fast & Slow Pointers |
| "Top k", "kth largest" | Heap |
| Key-value lookups, frequencies | Hash Map |
๐ฌIn the Real World...
In real interviews, communicating your pattern recognition is as important as the solution: "I see a subarray problem with a sum condition, this looks like a variable sliding window. Let me think about the expand/contract conditions."
๐คQuick Check
A problem asks: "Find all unique triplets in an array that sum to zero." Which pattern?
๐ฏ
Phase Complete!
Interview Patterns
You've completed the DSA & Algorithms track! You understand complexity, every major data structure, and the top interview patterns. You're interview-ready. Keep practicing!
0/500
Practice Exercises
0/2 solvedExercise 1 of 2hard
โฑ 00:00Three Sum
Find all unique triplets that sum to zero. Use sort + two pointers.
Expected output:
Expected output:
[[-1, -1, 2], [-1, 0, 1]]solution.py
1 / 2
Exercise 2 of 2medium
โฑ 00:00Word Break
Given a string and a word dictionary, can the string be segmented into dictionary words?
Expected output:
Expected output:
Truesolution.py
2 / 2
Solve all 2 exercises to unlock completion