Mock 02 — Easy LeetCode
Interview type: Standard LC easy Target role: Intern, new grad SWE-I, first technical screen Time limit: 30 minutes Format: 1 easy problem Hints policy: One free hint after 10 min of being stuck; additional hints -1 each Primary goal: Solve correctly with clean code and adequate testing in under 30 min.
What This Mock Tests
The bar at the easy level: you should solve the problem with the optimal approach, communicate clearly throughout, and verify with at least 2 unprompted tests. Easy LC questions are the most common phone-screen problems at smaller companies and at the start of FAANG screens.
Scoring weights are uniform across dimensions — easy LCs should pass on every axis.
Pick One Problem
Problem A — Two Sum (LC 1)
Given an array of integers nums and an integer target, return the indices of the two numbers that add up to target. You may assume exactly one solution exists. You may not use the same element twice.
Examples:
nums = [2, 7, 11, 15], target = 9 → [0, 1]
nums = [3, 2, 4], target = 6 → [1, 2]
nums = [3, 3], target = 6 → [0, 1]
Constraints: 2 ≤ |nums| ≤ 10^4. -10^9 ≤ nums[i] ≤ 10^9. Exactly one solution.
Problem B — Best Time to Buy and Sell Stock (LC 121)
You are given prices, where prices[i] is the price of a stock on day i. Maximize profit by choosing one day to buy and a later day to sell. If no profit possible, return 0.
Examples:
[7, 1, 5, 3, 6, 4] → 5 (buy day 1 at 1, sell day 4 at 6)
[7, 6, 4, 3, 1] → 0
[1, 2] → 1
Constraints: 1 ≤ |prices| ≤ 10^5. 0 ≤ prices[i] ≤ 10^4.
Problem C — Contains Duplicate (LC 217)
Given an integer array nums, return True if any value appears at least twice.
Examples:
[1, 2, 3, 1] → True
[1, 2, 3, 4] → False
[1, 1, 1, 3, 3, 4, 3, 2, 4, 2] → True
Constraints: 1 ≤ |nums| ≤ 10^5.
Expected Communication Style
- Restate the problem in 1 sentence.
- Ask 2–3 clarifying questions: input bounds, edge cases (empty? duplicates? negative?), output format.
- State brute force with complexity. (“Nested loop, O(N²).”)
- Identify the optimization signal. (“I see lookup-by-value — hashmap.”)
- State optimal complexity before coding. (“O(N) time, O(N) space.”)
- Code with brief narration of each step.
- Walk through given example. Then 1–2 edge cases.
Solution Sketches
A. Two Sum: hashmap value → index; for each element, check if target - x is in the map; if so return; else insert. O(N) time, O(N) space.
B. Stock: maintain running minimum; for each price, compute price - min_so_far; track max. O(N) time, O(1) space.
C. Duplicate: insert into a set; on collision return True. O(N) time, O(N) space. Or: sort + scan adjacent, O(N log N) time, O(1) extra.
Common Failure Modes
- Wrote the O(N²) brute force as the final answer. Acceptable on first attempt, but you must immediately follow with the optimization.
- Forgot to handle duplicates in Two Sum. What if
nums = [3, 3]? The naive hashmap solution must checktarget - xbefore insertingx. - Used
max(prices) - min(prices)for B. Wrong — the min must come before the max. - No edge case test. Empty arrays, single element, all duplicates.
Passing Bar
- Total score: 42/70 (average 3.0)
- Optimal complexity reached (O(N) or O(N log N) depending on problem)
- At least 2 unprompted edge case tests
- Continuous narration (no silent stretches >30 sec)
Follow-up Questions
For A:
- What if there are multiple valid pairs? Return all. → Need to handle duplicates carefully; either set of tuples or sort + two-pointer.
- What if the array is sorted? → Two-pointer, O(1) extra space.
- What if the input is a stream? → Hashmap still works; can’t know “future” elements.
- What if duplicates matter? →
nums = [3, 3], target = 6→ return [0, 1].
For B:
- Can you buy and sell multiple times? → LC 122; sum all positive day-to-day differences.
- With a cooldown of K days between trades? → DP, state = (day, holding?).
- With a transaction fee? → DP variant.
- What if you can short-sell? → Symmetric; maintain running max.
For C:
- What if memory is constrained? → Bloom filter (approximate); or sort in-place + scan.
- Return the first duplicate, not just whether one exists. → Same approach, return on first collision.
- Find ALL duplicates. → Count map.
- In a stream? → Bloom filter or Count-Min Sketch for approximate.
Required Tests
For all:
- Given examples
- Empty input or smallest legal input
- Single-element input (if applicable)
- Edge case specific to the problem (negative numbers, all-duplicates, sorted input)
Required Complexity Explanation
State:
- Time complexity (with reasoning)
- Space complexity (with reasoning)
- The bottleneck — which line determines the dominant cost
Self-Evaluation Template
Mock 02 — Easy LC
Date: _______
Problem: _______
Time taken: _____ / 30 min
Scores (1–5) for all 14 dimensions:
___ Total /70
Optimal complexity reached? Y/N
Hints used? Number: ___
Edge cases tested unprompted? Number: ___
Strongest dimension:
Weakest dimension:
Action item for next mock:
What to Do If You Fail
- Score 35–41: Re-do with a different problem from the list. Focus on the lowest-scored dimension.
- Score <35: Step back to Mock 01 for one session. The habit loop isn’t solid.
- Failed to reach optimal complexity: Drill Phase 1 (foundations) hash-map and array labs.
- Took longer than 30 min: Repeat with a stricter timer. 30 min is the actual phone-screen budget.