Master the UMPIRE framework and instantly recognize 30+ coding patterns. Learn Toptal's exact evaluation criteria, optimize for every complexity tier, write production-quality code under pressure, and execute a proven 8-week (60-day) study plan covering 75+ must-solve problems.
Understand the exact format, evaluation criteria, and scoring methodology. 90 minutes. 3 problems. Precision matters.
| Aspect | Details |
|---|---|
| Duration | 90 minutes total |
| Problems | 3 (typically Easy, Medium, Hard) |
| Environment | Web-based IDE with syntax highlighting |
| Languages | C#, Java, Python, JavaScript, Go, C++, Rust |
| Test Cases | Visible + Hidden (no access to hidden until submit) |
| Resubmission | Unlimited (no penalty) |
| Compilation | Real-time error feedback |
| Criterion | Weight | What Reviewers Check |
|---|---|---|
| Correctness | 40% | Passes all test cases (visible & hidden). Handles edge cases. Logic is sound. |
| Efficiency | 30% | Time complexity optimal or near-optimal. Space usage reasonable. No TLE (Time Limit Exceeded). |
| Edge Cases | 20% | Empty inputs, single element, negatives, overflow, unicode, duplicates, off-by-one. All handled explicitly. |
| Code Quality | 10% | Clear naming, no magic numbers, helper methods, readable structure, proper formatting. |
Toptal's hidden tests typically check:
A six-step methodology that eliminates guessing and reduces careless errors. Follow this for every single problem.
Problem: Given array of integers and target sum, return indices of two numbers that add to target. Use each element at most once.
public int[] TwoSum(int[] nums, int target) { var map = new Dictionary<int, int>(); for (int i = 0; i < nums.Length; i++) { int complement = target - nums[i]; if (map.ContainsKey(complement)) return new int[] { map[complement], i }; if (!map.ContainsKey(nums[i])) map[nums[i]] = i; } return new int[] { }; }
Instantly recognize problem types by signal words. This table is your cheat sheet.
| Pattern | Signal Words | Technique | Why It Works | LC Examples | Chapter |
|---|---|---|---|---|---|
| Two Pointers | Sorted, pair, target, reverse, meeting | Converging pointers from ends | Exploit ordering to eliminate binary search | #1, #15, #11, #167 | Ch. 5 |
| Sliding Window | Subarray, substring, longest, shortest, contiguous | Expand/contract window with 2 pointers | Each element enters/exits once = O(n) | #3, #76, #209, #424 | Ch. 6 |
| Hash Map | Duplicate, frequency, count, anagram, complement | Map value→count or value→index | O(1) lookup replaces O(n) search | #1, #49, #242, #347 | Ch. 7 |
| Prefix Sum | Subarray sum, range, cumulative, zero-sum | Precompute cumulative sums | Range sum O(n) → O(1) | #303, #560, #724 | Ch. 9 |
| Binary Search | Sorted, find position, log complexity, rotation | Divide search space by 2 | Eliminate half remaining options each step | #704, #35, #74, #153 | Ch. 8 |
| Monotonic Stack | Next greater, previous smaller, trapping, histogram | Push/pop to maintain monotonic order | Each element pushed/popped once = O(n) | #20, #155, #739, #84 | Ch. 10 |
| BFS / Queue | Shortest path, level order, distance, matrix layers | Layer-by-layer exploration with queue | Guarantees shortest path in unweighted graph | #102, #542, #994, #1091 | Ch. 13 |
| DFS / Recursion | Traversal, path, permutation, reachability, connected | Recursive or stack-based graph traversal | Explores all paths; backtracking prunes branches | #104, #200, #332, #46 | Ch. 12 |
| Fast-Slow Pointers | Cycle, middle, kth from end, circular list | Two pointers: one 2x speed | Floyd's algorithm: meeting point indicates cycle | #141, #142, #876, #202 | Ch. 11 |
| Tree Recursion | Depth, path, LCA, balanced, diameter, subtree sum | Recurse on left/right, combine results | Leverage subtree solutions for superproblems | #104, #110, #236, #257 | Ch. 12 |
| BST Property | Search tree, validate, in-order, kth, successor | In-order → sorted; use min/max bounds | BST property eliminates half of tree | #98, #230, #700, #235 | Ch. 12 |
| Union-Find | Connected, components, cycle, grouping, parent | Maintain connected components via parent pointers | O(α(n)) amortized for find/union | #684, #547, #323, #1319 | Ch. 14 |
| Topological Sort | Prerequisite, dependency, DAG, ordering, course | Kahn (BFS) or DFS for dependency order | Detects cycles; ensures deps processed first | #207, #210, #269, #310 | Ch. 14 |
| Dijkstra | Shortest path, positive weights, weighted graph | Priority queue: always process min distance | Greedy: shortest path to node is final | #743, #787, #882, #1334 | Ch. 14 |
| 0/1 DP | Climb stairs, house robber, partition, max | dp[i]=best solution for subproblem i | Avoid recalculating overlapping subproblems | #70, #198, #322, #416 | Ch. 15 |
| Unbounded DP | Coin change, unlimited, target sum, combinations | Item can be used multiple times | Recurrence: dp[i] uses all smaller j | #322, #518, #494, #377 | Ch. 15 |
| 2D DP | Edit distance, unique paths, max square, triangle | dp[i][j]=solution for subgrid (i,j) | 2D state space: explore all cell combinations | #64, #62, #97, #1143 | Ch. 15 |
| Knapsack | Weight capacity, subset sum, target, bounded | dp[i][w]=max value with i items, weight w | Item taken or skipped; optimize weight | #416, #1049, #474, #494 | Ch. 15 |
| Greedy | Interval, activity, max profit, minimum cost, sort | Make locally optimal choice at each step | Works when greedy leads to global optimum | #435, #452, #945, #881 | Ch. 16 |
| Backtracking | Permutation, combination, subset, N-Queens, Sudoku | Explore all possibilities; prune invalid branches | Systematically exhaust with early termination | #46, #47, #78, #51 | Ch. 17 |
| Bit Manipulation | Power of 2, bit count, XOR swap, subset, mask | AND/OR/XOR/shift for compact operations | O(1) bit ops vs. O(n) array ops | #191, #231, #136, #268 | Ch. 4 |
| Math/Number Theory | Palindrome, prime, GCD, Fibonacci, modular, digit | Apply mathematical insight instead of brute force | Skip redundant computation via math property | #204, #172, #69, #1401 | Ch. 3 |
| Heap / Priority Queue | Kth largest, median, top K, frequent, min/max | Min/Max heap for quick access to extreme | O(log n) insertion; O(1) peak access | #215, #295, #347, #313 | Ch. 10 |
| Graph Coloring | Bipartite, conflict, map coloring, scheduling | Assign colors: no adjacent same color | BFS/DFS detects odd cycles; 2 colors = bipartite | #785, #1042, #886, #210 | Ch. 13 |
| Interval Merging | Merge overlapping, non-overlapping, insert, schedule | Sort by start; merge if overlapping | Linear scan post-sort identifies all overlaps | #56, #57, #435, #986 | Ch. 6 |
| Matrix Traversal | Spiral, rotate, search sorted, spiral order | Row-major, spiral, or direction-change iteration | Layer-by-layer approach handles complexity | #54, #48, #240, #1572 | Ch. 6 |
| Simulation | State machine, game logic, step-by-step, rules | Implement rules directly; iterate state | Sometimes no pattern; just simulate correctly | #54, #67, #1306, #1849 | Ch. 2 |
| Trie | Word search, autocomplete, prefix, dictionary | Tree of characters; each node has children | O(m) word search vs. O(m log n) hash | #208, #211, #212, #1268 | Ch. 10 |
| Segment Tree/Fenwick | Range query, point update, sum rectangle | Build tree for fast range aggregation | O(log n) query/update vs. O(n) naive | #307, #308, #1157, #1606 | Ch. 10 |
Match input size to target complexity class. This prevents TLE and guides algorithm selection.
| Input Size (n) | Typical Operations | Target Complexity | Algorithm Examples |
|---|---|---|---|
| n ≤ 10 | ~10M ops | O(n!) or O(n^6) | Brute force all permutations, full backtracking |
| n ≤ 20 | ~1M ops | O(2^n) or O(n^5) | Bitmask DP, subset enumeration, exponential |
| n ≤ 500 | ~250K ops | O(n^3) or O(n^2 log n) | Floyd-Warshall, DP with 2D state, cubic iteration |
| n ≤ 10^4 | ~100M ops | O(n^2) | Nested loops, bubble sort, all pairs |
| n ≤ 10^5 | ~1B ops | O(n log n) | Merge sort, heap sort, binary search variants |
| n ≤ 10^6 | ~1B ops | O(n) or O(n log n) | Single pass, hash map, sorting, linear scan |
| n ≤ 10^8 | ~100M ops | O(n) only | Must be linear; very tight constants required |
| n > 10^8 | Varies | O(log n) | Binary search, bit operations, math only |
C#-specific tricks to write faster, safer, cleaner code in contests.
| Feature | Usage | Time/Space |
|---|---|---|
| Dictionary<K,V> | Hash map for O(1) lookup | O(1) avg, O(n) worst |
| HashSet<T> | Fast membership testing, deduplication | O(1) avg Add/Contains |
| List<T> | Dynamic array, sorted lists | O(n) insertion, O(1) access |
| Queue<T> | BFS, level-order traversal | O(1) Enqueue/Dequeue |
| Stack<T> | DFS, monotonic stack, parsing | O(1) Push/Pop |
| PriorityQueue<T> (C# 10+) | Min/Max heap, Dijkstra | O(log n) Enqueue/Dequeue |
| SortedDictionary<K,V> | Ordered key access, range queries | O(log n) operations |
| StringBuilder | String concatenation (never use + in loop) | O(n) for n appends vs O(n²) |
| Array.Sort(T[], IComparer) | Custom sort order with comparers | O(n log n) |
1. StringBuilder for String Building
string result = ""; for (int i = 0; i < 1000; i++) result += i.ToString(); // O(n²) string copying!
var sb = new StringBuilder(); for (int i = 0; i < 1000; i++) sb.Append(i); // O(n) string result = sb.ToString();
2. Dictionary Patterns
// Count frequencies var freq = new Dictionary<int, int>(); foreach (int num in nums) freq[num] = freq.GetValueOrDefault(num, 0) + 1; // Or use TryGetValue for safety if (freq.TryGetValue(key, out int val)) // Use val safely
3. PriorityQueue (C# 10+)
var minHeap = new PriorityQueue<int, int>(); minHeap.Enqueue(5, 5); // value, priority minHeap.Enqueue(3, 3); int min = minHeap.Dequeue(); // 3 // For max heap, negate priorities var maxHeap = new PriorityQueue<int, int>(); maxHeap.Enqueue(5, -5); // negate
4. LINQ Gotchas
.ToList() to materialize.OrderBy() is O(n log n); don't call multiple times on result.Count() on IEnumerable is O(n); pre-materialize for multiple uses..FirstOrDefault() is safer than .First() for empty sequences.5. Span<T> for Performance
// Use Span<T> for zero-copy slicing int[] arr = new int[] { 1, 2, 3, 4, 5 }; Span<int> slice = arr.AsSpan(1, 3); // No allocation
6. Integer Overflow Safety
// Check bounds before arithmetic if (a > int.MaxValue - b) // would overflow // Use long for large intermediate values long product = (long)a * b;
7. Array.Sort with Custom Comparer
// Sort by custom logic Array.Sort(intervals, (a, b) => a[0].CompareTo(b[0])); // Or reverse order Array.Sort(nums, (a, b) => b.CompareTo(a));
8. Common Math Methods
Math.Abs(x); Math.Max(a, b); Math.Min(a, b); Math.Pow(base, exp); Math.Sqrt(x); Math.Floor(x); Math.Ceiling(x); x % m; // modulo
These account for 20% of your score. Missing one means wrong answer on hidden tests.
| Category | Examples to Test | Code Implications |
|---|---|---|
| Empty Input | [], "", null, 0 length | Check array bounds before access. Handle null gracefully. |
| Single Element | n=1, one node, one char | Loops should handle i=0 case. Base case matters. |
| Duplicates | All same value, freq=n | Dict handling, set dedup, comparison logic. |
| Sorted/Reverse | Ascending, descending, already sorted | Early exit conditions, comparison directions. |
| Negatives | All negative, mixed signs, -1 | Abs(), sign handling, comparison logic. |
| Zero | Zeros in array, divide by zero | Check denominator != 0. Handle x=0 specially. |
| Integer Overflow | int.MaxValue, near limits | Use long, check before arithmetic, modulo. |
| Large Input | n=10^6, stress memory | O(n²) becomes TLE. Use efficient structures. |
| Off-by-One | Boundary indices, fencepost | Loop conditions: i < n vs i <= n. Array indices. |
| Unicode/Special Chars | UTF-8, emoji, accents, newlines | String length vs byte length. Char encoding. |
| Floating Point | NaN, Infinity, rounding | Equality checks use epsilon. Integer conversion issues. |
| Null/Undefined | null references, uninitialized | Null checks. Dictionary.TryGetValue not direct access. |
The final 10% of your score. Clean code reads like prose. Make reviewers happy.
TwoSum, IsValid, BuildGraphleftPointer, freqMap, resultMAX_SIZE or MaxSizeisValid, hasNext, canReachif (i % 2 == 0) is unclear. Better: const int MOD = 2; if (i % MOD == 0). Or comment: // Check if evenIsValid(), GetNeighbors(), Swap() make main logic readable.// Greedy: always pick min cost option is better than // Loop through arrayBEFORE (Poor Quality):
public bool isvalid(string s) { var st = new Stack<char>(); for(int i=0;i<s.Length;i++) { char c=s[i]; if(c=='('||c=='{'||c=='[')st.Push(c); else { if(st.Count==0)return false; char t=st.Pop(); if(!(c==')'&&t=='('||c=='}'&&t=='{'||c==']'&&t=='['))return false; } } return st.Count==0; }
AFTER (Good Quality):
public bool IsValid(string s) { var stack = new Stack<char>(); foreach (char c in s) { if (IsOpeningBracket(c)) { stack.Push(c); } else if (IsClosingBracket(c)) { if (stack.Count == 0 || !IsMatching(stack.Pop(), c)) return false; } } return stack.Count == 0; } private bool IsOpeningBracket(char c) => c == '(' || c == '{' || c == '['; private bool IsClosingBracket(char c) => c == ')' || c == '}' || c == ']'; private bool IsMatching(char open, char close) => (open == '(' && close == ')') || (open == '{' && close == '}') || (open == '[' && close == ']');
Solve these and you'll recognize 90% of interview questions. Organized by category and difficulty.
| Problem | LC# | Difficulty | Pattern | Chapter |
|---|---|---|---|---|
| Two Sum | #1 | Easy | Hash Map | 7 |
| Best Time to Buy & Sell Stock | #121 | Easy | Dynamic Programming | 15 |
| Contains Duplicate | #217 | Easy | Hash Set | 7 |
| 3Sum | #15 | Medium | Two Pointers | 5 |
| Product of Array Except Self | #238 | Medium | Prefix Sum | 9 |
| Merge Intervals | #56 | Medium | Interval Merging | 6 |
| Search in Rotated Sorted Array | #33 | Medium | Binary Search | 8 |
| Maximum Subarray | #53 | Medium | Dynamic Programming | 15 |
| Spiral Matrix | #54 | Medium | Matrix Traversal | 6 |
| Set Matrix Zeroes | #73 | Medium | In-Place Modification | 2 |
| Rotate Image | #48 | Medium | Matrix Rotation | 6 |
| First Missing Positive | #41 | Hard | Array Indexing | 2 |
| Problem | LC# | Difficulty | Pattern | Chapter |
|---|---|---|---|---|
| Valid Parentheses | #20 | Easy | Stack | 10 |
| Reverse String | #344 | Easy | Two Pointers | 5 |
| Longest Substring Without Repeating Chars | #3 | Medium | Sliding Window | 6 |
| Group Anagrams | #49 | Medium | Hash Map | 7 |
| Valid Palindrome | #125 | Medium | Two Pointers | 5 |
| Longest Palindromic Substring | #5 | Medium | Dynamic Programming | 15 |
| Word Ladder | #127 | Medium | BFS | 13 |
| Edit Distance | #72 | Hard | 2D DP | 15 |
| Word Break II | #140 | Hard | Backtracking DP | 17 |
| Regular Expression Matching | #10 | Hard | 2D DP | 15 |
| Problem | LC# | Difficulty | Pattern | Chapter |
|---|---|---|---|---|
| Reverse Linked List | #206 | Easy | Linked List Manipulation | 11 |
| Merge Two Sorted Lists | #21 | Easy | Two Pointers | 5 |
| Linked List Cycle | #141 | Easy | Fast-Slow Pointers | 11 |
| Add Two Numbers | #2 | Medium | Linked List Traversal | 11 |
| Remove Nth Node From End | #19 | Medium | Two Pointers | 5 |
| Reorder List | #143 | Medium | Fast-Slow + Reverse | 11 |
| Copy List with Random Pointer | #138 | Medium | Hash Map | 7 |
| LRU Cache | #146 | Hard | Hash Map + Linked List | 11 |
| Problem | LC# | Difficulty | Pattern | Chapter |
|---|---|---|---|---|
| Binary Tree Inorder Traversal | #94 | Easy | Tree Traversal | 12 |
| Invert Binary Tree | #226 | Easy | Tree Recursion | 12 |
| Same Tree | #100 | Easy | Tree Comparison | 12 |
| Balanced Binary Tree | #110 | Easy | Tree Recursion | 12 |
| Lowest Common Ancestor of BST | #235 | Easy | BST Property | 12 |
| Binary Tree Level Order | #102 | Medium | BFS | 13 |
| Binary Tree Zigzag Traversal | #103 | Medium | BFS | 13 |
| Lowest Common Ancestor | #236 | Medium | Tree Recursion | 12 |
| Validate BST | #98 | Medium | BST Property | 12 |
| Path Sum II | #113 | Medium | Backtracking | 17 |
| Number of Islands | #200 | Medium | DFS/BFS | 13 |
| Clone Graph | #133 | Medium | Graph Traversal | 13 |
| Course Schedule | #207 | Medium | Topological Sort | 14 |
| Binary Tree Maximum Path Sum | #124 | Hard | Tree Recursion | 12 |
| Alien Dictionary | #269 | Hard | Topological Sort | 14 |
| Problem | LC# | Difficulty | Pattern | Chapter |
|---|---|---|---|---|
| Climbing Stairs | #70 | Easy | 0/1 DP | 15 |
| House Robber | #198 | Medium | 0/1 DP | 15 |
| Coin Change | #322 | Medium | Unbounded DP | 15 |
| Unique Paths | #62 | Medium | 2D DP | 15 |
| Partition Equal Subset Sum | #416 | Medium | Knapsack | 15 |
| Word Break | #139 | Medium | 1D DP | 15 |
| Longest Increasing Subsequence | #300 | Medium | 1D DP | 15 |
| Target Sum | #494 | Medium | Knapsack | 15 |
| Distinct Subsequences | #115 | Hard | 2D DP | 15 |
| Interleaving String | #97 | Hard | 2D DP | 15 |
| Best Time to Buy Stock IV | #188 | Hard | DP with State | 15 |
| Longest Substring w/ At Most K Distinct | #340 | Hard | Sliding Window DP | 6 |
| Problem | LC# | Difficulty | Pattern | Chapter |
|---|---|---|---|---|
| Trapping Rain Water | #42 | Medium | Monotonic Stack | 10 |
| Largest Rectangle in Histogram | #84 | Medium | Monotonic Stack | 10 |
| Kth Largest Element | #215 | Medium | Heap/Quickselect | 10 |
| Top K Frequent Elements | #347 | Medium | Heap | 10 |
| Find Median from Data Stream | #295 | Hard | Heap | 10 |
| Meeting Rooms II | #253 | Medium | Greedy Sorting | 16 |
| Interval Scheduling Maximization | #452 | Medium | Greedy | 16 |
| Two Sum III - Data Structure Design | #170 | Medium | Hash Map | 7 |
| Sort Colors | #75 | Medium | Two Pointers | 5 |
| Minimum Window Substring | #76 | Hard | Sliding Window | 6 |
| Permutations | #46 | Medium | Backtracking | 17 |
| Combinations | #77 | Medium | Backtracking | 17 |
| Subsets | #78 | Medium | Backtracking | 17 |
| Letter Combinations | #17 | Medium | Backtracking | 17 |
| N-Queens | #51 | Hard | Backtracking | 17 |
| Sudoku Solver | #37 | Hard | Backtracking | 17 |
| Surrounded Regions | #130 | Medium | DFS/BFS | 13 |
| Accounts Merge | #721 | Medium | Union-Find | 14 |
You have 60 days — use them wisely. This 8-week plan at ~2 hrs/day gives you 120 total hours of deep, structured practice. That's 3x what most candidates invest.
Goal: Master Big O, arrays, strings, prefix sums. Solve all easy Codility problems. 100% on Codility Lessons 1-5.
Mon: Big O & Complexity (Ch 1). Practice estimating complexity from code snippets. (2 hrs)
Tue: Arrays & Strings (Ch 2). C# arrays, List, StringBuilder. Codility Lessons 1-2. (2 hrs)
Wed: Prefix Sums (Ch 19). Codility Lesson 5. Solve: PassingCars, GenomicRangeQuery, MinAvgTwoSlice. (2 hrs)
Thu: Counting Elements. Codility Lesson 3-4. Solve: MissingInteger, MaxCounters, PermCheck. (2 hrs)
Fri: Practice: Solve 5 easy problems timed (10 min each). Review edge cases. (2 hrs)
Sat: Revisit any problems not at 100%. Write prefix sum template from memory 3 times. (3 hrs)
Sun: Light review. Rest.
Goal: Master hash maps, two pointers, sliding window, binary search, stacks. Take Mock Test 1.
Week 2 Mon-Fri: Hash Maps (Ch 5), Two Pointers & Sliding Window (Ch 15), Binary Search (Ch 10). 2 problems/day. (2 hrs/day)
Week 2 Sat: Sorting algorithms (Ch 9). Codility Lesson 6. Problems: Distinct, Triangle, NumberOfDiscIntersections. (3 hrs)
Week 3 Mon-Fri: Stacks & Queues (Ch 4). Monotonic stack. Problems: Brackets, Fish, StoneWall, Largest Rectangle, Daily Temperatures. (2 hrs/day)
Week 3 Sat: Review all patterns. Re-solve 5 hardest problems from Weeks 2-3. (3 hrs)
Week 3 Sun: MOCK TEST 1 (90 min timed). Score target: 200+/300. (3 hrs)
Goal: Master trees, graphs, heaps, linked lists. Complete ALL 17 Codility lessons at 100%. Take Mock Test 2.
Week 4 Mon-Wed: Linked Lists (Ch 3). Problems: Reverse, Merge, Cycle Detection, Palindrome. (2 hrs/day)
Week 4 Thu-Sat: Trees & BST (Ch 6). Traversals, Validate BST, LCA, Path Sum, Kth Smallest. (2-3 hrs/day)
Week 5 Mon-Wed: Graphs (Ch 8). BFS, DFS, Dijkstra. Problems: Number of Islands, Course Schedule, Word Ladder. (2 hrs/day)
Week 5 Thu-Fri: Heaps (Ch 7). PriorityQueue. Codility Lessons 8-17 (complete ALL). (2 hrs/day)
Week 5 Sat: Verify ALL 17 Codility lessons are 100%. Fix any that aren't. (3 hrs)
Week 5 Sun: MOCK TEST 2 (90 min timed). Score target: 230+/300. (3 hrs)
Goal: Master DP, greedy, backtracking. Solve 50+ medium/hard problems. Take Mock Test 3.
Week 6 Mon-Wed: Dynamic Programming (Ch 12). 1D DP: Climbing Stairs, House Robber, Coin Change, LIS. (2 hrs/day)
Week 6 Thu-Fri: 2D DP: Edit Distance, LCS, Knapsack, Unique Paths. Draw DP tables by hand. (2 hrs/day)
Week 6 Sat: DP Advanced: Stock with Cooldown, Burst Balloons concept, bitmask intro. (3 hrs)
Week 7 Mon-Tue: Greedy (Ch 13): Jump Game, Gas Station, Task Scheduler, Partition Labels. (2 hrs/day)
Week 7 Wed-Thu: Backtracking (Ch 11): Subsets, Permutations, Combination Sum, N-Queens. (2 hrs/day)
Week 7 Fri: Strings, Bit Manipulation, Intervals — solve remaining problems. (2 hrs)
Week 7 Sat: Hard Problem Day: 3 hard problems (1 DP, 1 graph, 1 design). 40 min each. (3 hrs)
Week 7 Sun: MOCK TEST 3 (90 min timed). Score target: 250+/300. (3 hrs)
Goal: Score 260+/300 consistently. Prepare for all 4 Toptal rounds. Build supreme confidence.
Day 50-51: Weak point audit. Identify 2 weakest categories. Drill those exclusively. (2 hrs/day)
Day 52-53: Speed drills: 6 easy in 60 min, 3 mediums in 75 min. Edge case mastery. (2 hrs/day)
Day 54: Random problem mix from LeetCode — no category chosen. Practice pattern recognition. (2 hrs)
Day 55: MOCK TEST 4 (full simulation, no breaks). Target: 270+/300. (3 hrs)
Day 56: Live Coding prep (REACTO method). Practice talking through solutions aloud. (3 hrs)
Day 57: Take-Home Project prep. Set up .NET template with Clean Architecture, DI, tests. (2 hrs)
Day 58: Communication Round prep. Practice answering common questions aloud. (2 hrs)
Day 59: FINAL MOCK TEST. Dress rehearsal. Score target: 260+/300. (2 hrs)
Day 60: Light review of cheatsheet and golden rules. No new problems. Sleep early. You're ready.
How to think under pressure, communicate, and recover. Master this and you'll ace the real test.
Learn from others' failures. These 20 mistakes cost interview offers.
| Mistake | Why It Fails | Fix |
|---|---|---|
| Skipping edge cases | Hidden tests catch empty, single element, overflow | Always test: [], [1], max values |
| Off-by-one errors | Loop conditions wrong; access out of bounds | Trace: i < n vs i <= n. Check indices. |
| Modifying input | Problem says don't modify; you did. Wrong answer. | Use auxiliary arrays/maps instead. |
| Integer overflow | a + b overflows to negative; logic breaks | Use long, check before arithmetic. |
| Wrong complexity | O(n²) on n=10^5 = TLE | Match input size to complexity target. |
| Forgetting to return | Function returns null; crashes | Check all paths return a value. |
| Mutating shared state | If multiple test cases, leftover data breaks next test | Initialize fresh variables each run. |
| String concatenation in loops | O(n²) copying; TLE | Use StringBuilder. |
| Assuming sorted input | Problem never says sorted; you assume it | Reread constraints. Don't assume. |
| Dictionary access without check | KeyNotFoundException when key missing | Use TryGetValue or GetValueOrDefault. |
| Modifying collection during iteration | IndexOutOfRangeException or skip elements | Build new list or iterate over copy. |
| Floating-point equality | 0.1 + 0.2 != 0.3 due to precision | Use epsilon: Math.Abs(a - b) < 1e-9 |
| Not null-checking | NullReferenceException on null input | Check params: if (s == null) return ... |
| Wrong complexity analysis | "It's O(n)!" but actually O(n²)" | Count nested loops, recursion depth. |
| Not testing with examples | Code passes visible tests, fails hidden | Always run all provided examples first. |
| Unclear variable names | Reviewers dock points for readability | Use descriptive names: leftPointer, freqMap |
| Magic numbers | "What does 2 mean?" Code unclear | const int MOD = 2; or comment why. |
| No comments on complex logic | Reviewers can't follow intent | Comment the WHY: "Greedy: pick min..." |
| Inefficient brute force | Correct but O(n³); TLE | Optimize to O(n log n) or O(n). |
| Forgetting base case in recursion | Stack overflow or infinite recursion | Always define: if (n == 0) return ... |
One-page summary of critical facts. Print and review 1 hr before test.
| Data Structure | Access | Search | Insert | Delete | Space |
|---|---|---|---|---|---|
| Array | O(1) | O(n) | O(n) | O(n) | O(n) |
| Hash Table | O(1) | O(1) | O(1) | O(1) | O(n) |
| Linked List | O(n) | O(n) | O(1) | O(1) | O(n) |
| Stack | O(n) | O(n) | O(1) | O(1) | O(n) |
| Queue | O(n) | O(n) | O(1) | O(1) | O(n) |
| Binary Tree | O(log n) | O(log n) | O(log n) | O(log n) | O(n) |
| Heap | O(1) | O(n) | O(log n) | O(log n) | O(n) |
| Graph (Adjacency List) | — | O(V+E) | O(1) | O(V) | O(V+E) |
| Trie | — | O(m) | O(m) | O(m) | O(ALPHABET_SIZE * N) |
Is the input sorted?
Is it a graph/tree problem?
Can you build optimal solution from subproblems?
Is it a string/substring problem?
Is it an optimization problem (max/min)?
O(1) < O(log n) < O(√n) < O(n) < O(n log n) < O(n²) < O(n³) < O(2ⁿ) < O(n!)
Dictionary<K,V> for hash maps. .TryGetValue() to avoid crashes.HashSet<T> for membership. .Contains() O(1).PriorityQueue<T, P> for heaps. Negate priority for max heap.StringBuilder for string building. Never += in loops.Stack<T> for DFS/monotonic. Queue<T> for BFS.int.MaxValue for overflow checks. Use long for large arithmetic.Beyond the basics: techniques used by top performers in competitive programming.
Memoization (Top-Down DP): Start from the problem and recursively solve subproblems, caching results. Easier to code, but risk of stack overflow.
Tabulation (Bottom-Up DP): Build solution from base cases upward. More efficient, no recursion overhead, better for large inputs.
Example: Fibonacci
Memoization:
private int[] memo; public int Fib(int n) { if (memo[n] != -1) return memo[n]; if (n <= 1) return n; memo[n] = Fib(n - 1) + Fib(n - 2); return memo[n]; }
Tabulation:
public int Fib(int n) { int[] dp = new int[n + 1]; dp[0] = 0; dp[1] = 1; for (int i = 2; i <= n; i++) dp[i] = dp[i - 1] + dp[i - 2]; return dp[n]; }
DFS (Depth-First Search): General graph/tree traversal. Visit all nodes. Use when you need to explore entire structure.
Backtracking: DFS + constraint checking. Prune branches that violate constraints. Use for permutations, combinations, Sudoku, N-Queens.
Key Difference: Backtracking explicitly undoes choices (removes from current solution set) when backtracking. DFS just visits.
Standard Binary Search: Find exact element in sorted array.
Left Boundary: Find leftmost position of target.
Right Boundary: Find rightmost position of target.
Insert Position: If target not found, return insertion position.
Rotated Array: Find peak or search in rotation point.
Converging: Start from both ends, move toward middle. E.g., #1 (Two Sum sorted), #125 (Valid Palindrome).
Fast-Slow: One pointer 2x speed. E.g., #141 (Linked List Cycle), #876 (Middle of Linked List).
Sliding: Both move in same direction, window size varies. E.g., #3 (Longest Substring), #209 (Minimum Subarray).
| Goal | BFS or DFS? | Why | Example |
|---|---|---|---|
| Shortest path (unweighted) | BFS | Guarantees shortest | #127 (Word Ladder) |
| All paths | DFS | Explore all | #797 (All Paths) |
| Connected components | Either | Both work; DFS uses less memory | #200 (Islands) |
| Cycle detection (undirected) | Either | Both work | #261 (Cycle) |
| Topological order | DFS | Natural fit | #207 (Courses) |
| Shortest path (weighted) | Dijkstra | Handles weights | #743 (Network Delay) |
Space Optimization: If dp[i] depends only on dp[i-1], use rolling array. O(n) space → O(1).
State Compression: Use bitmask for small state. E.g., #1495 (Happy Ending) with n≤20.
Convex Hull Trick: Optimize DP with monotonic property. Advanced, rarely needed in interviews.
When greedy works, prove with exchange argument:
Example: Activity Selection. Greedy: always pick activity ending earliest. Proof: if optimal picks different first activity, swap it with earliest-ending without losing future activities.
Arrays: Off-by-one in loops, not handling duplicates, modifying input when shouldn't.
Strings: Forgetting about unicode, space vs. trimming, case sensitivity.
Trees: Not handling null children, infinite recursion (missing base case), not checking if BST property holds.
Graphs: Visited set not updated, cycle detection missed, disconnected components ignored.
DP: Wrong subproblem definition, incorrect transitions, base case missing.
Greedy: Forgetting to prove greedy works, edge case where greedy fails.
Constant Factor Improvements:
array.Length in loop.ref and out to avoid struct copying.Span<T> for zero-copy slicing.Good signs: Interviewer asking follow-up questions about approach, edge cases, or improvements. Means they're engaged.
Red flags: Long silence. May indicate you're off track. Ask clarifying questions.
Recovery: If stuck, think aloud. "This looks like X, let me try..." Interviewer may nudge you.
Code Review Tab: They show you feedback on past submissions. Learn from it.
Discussion Forum: Read solutions, see different approaches. Don't copy; understand.
Practice Problems: Start easy, progressively harder. Don't skip medium to jump to hard.
After each mock or real test:
If you have 1 hour before test:
After passing Toptal, continue with: