Interview round · in depth
Coding interview practice: explain the approach, then run the tests
Practice coding interviews the way the round is run: clarify the problem, state a baseline, improve it, then prove it with tests. Lab drills run in a JavaScript or Python sandbox in your browser.
Free during early access. Practice runs in the app, which needs an account.
Prep sheetCoding
- 01Clarifying inputs and edge cases
- 02Hash maps, stacks and two pointers
- 03Sliding windows and heaps
- 04Complexity and testing
01Common prompts
Sample coding interview questions
These coding interview questions are practice prompts written or adapted by InterviewWare, not questions reported by any employer. Each comes with the signals an interviewer listens for and the follow-up that usually comes next.
| Question | What the interviewer listens for | Likely follow-up |
|---|---|---|
| R2 · Role depth & case | ||
| Q01 How would you find the first non-repeating character in a string? | Two passes with a count map for O(n) time, and a question about the character set before choosing a fixed-size array or a map. | What changes if the characters arrive as a stream and you must answer after each one? |
| Q02 Explain how you would detect a cycle in a linked list, and where it starts. | A visited set first, then fast and slow pointers for O(1) space, with an honest explanation of why they meet. | Why does moving one pointer back to the head find the entry of the cycle? |
| Q03 Check whether a binary tree is a valid binary search tree. | Lower and upper bounds passed down the recursion rather than comparing a node only with its children, and an explicit rule for duplicates. | How would you do it iteratively, and what does it cost in space on a skewed tree? |
| Q04 Count the islands in a grid of land and water cells. | BFS or DFS from each unvisited land cell, marking what has been visited, and a note on recursion depth for large grids. | If the grid changes one cell at a time, how would you keep the count without rescanning? |
| Q05 Return the k-th largest number in an unsorted array. | Sorting as the baseline, a size-k min-heap for O(n log k), and quickselect’s average O(n) with its worst case stated. | Which approach would you choose if the array does not fit in memory? |
| Q06 Given a list of daily prices, find the best profit from one buy followed by one sell. | One pass that tracks the lowest price so far; brute force mentioned but not written; an empty list and falling prices tested aloud. | What changes if you may buy and sell as many times as you like? |
02Try one question
Coding interview practice: talk through one problem
Draft an answer to one of the questions above. It stays in this browser until you ask for feedback.
Practice question · Coding
How would you find the first non-repeating character in a string?
Feedback needs a free account (one step, no card). Your draft is kept only in this browser and filled in after you sign up; nothing is sent until you submit it.
03Technical lab
Coding drills you can run in the lab
Each drill runs in JavaScript or Python against public tests in your browser. The table shows the pattern and the complexity an interviewer would usually expect.
| Drill | Pattern | Difficulty | Target time | Target space |
|---|---|---|---|---|
| 01Pair sum | Hash map | Easy | O(n) | O(n) |
| 02Balanced brackets | Stack | Easy | O(n) | O(n) |
| 03Search insert position | Binary search | Easy | O(log n) | O(1) |
| 04Merge sorted arrays | Two pointers | Easy | O(m + n) | O(m + n) |
| 05Merge intervals | Sorting · Intervals | Medium | O(n log n) | O(n) |
| 06Group anagrams | Hash map · Strings | Medium | O(n · k log k) | O(n · k) |
| 07Longest unique run | Sliding window · Hash map | Medium | O(n) | O(k) |
| 08Top K frequent | Hash map · Heap / buckets | Medium | O(n log k) | O(n) |
| 09LRU cache simulator | Design · Hash map + list | Medium | O(1) per operation | O(capacity) |
| 10Sliding window maximum | Monotonic deque · Sliding window | Hard | O(n) | O(k) |
Open the technical labRequires an account.
04Worked example
Return the k most frequent numbers in an array.
What to say before and after you code; mid-level, about two minutes of talking. Illustrative sample written by InterviewWare, not a real candidate’s answer.
- 01
Clarify
Can k exceed the number of distinct values, and does the order of the result matter? I’ll assume k is valid and any order is fine.
- 02
Baseline
Count with a hash map, then sort the distinct values by count: O(n log n) in the worst case.
- 03
Improve
Keep a min-heap of size k while scanning the counts, which gives O(n log k); bucketing by count would give O(n).
- 04
Test
Before calling it done, I’ll run a case with tied counts and a case where k equals the number of distinct values.
05Coaching notes
How to answer coding interview questions
What works
- T1Restate the problem and ask about input size, duplicates, empty input and the return type before you touch code.
- T2Say the brute-force idea and its complexity in one sentence, then improve it; interviewers want to see that step.
- T3Narrate while you write, and name the invariant your loop keeps.
- T4Before you say you’re done, walk one normal case and one edge case through the code by hand.
Common mistakes in coding interviews
- M1Coding in silence for ten minutes, so the interviewer can neither help nor credit your reasoning.
- M2Jumping to a memorised optimal solution you can’t explain.
- M3Quoting O(n) without saying what n is, or forgetting the space a hash map uses.
- M4Testing only the example given in the prompt.
- M5Naming variables a, b and tmp under pressure, then losing track of your own code.
06Tools that help
Tools for coding interview prep
- JS · PythonPublic tests
Technical interview lab
Run the drills below against public tests in JavaScript or Python, with nothing to install, and save a draft to discuss.
- 4 interviewersR1–R3Text · voice
Conversational AI mock interviews
Talk a saved solution through with the engineering-lead interviewer, who presses on complexity and the alternatives you rejected.
- PaceFillers · pauses
Interview speaking practice
Record a two-minute explanation of your approach and see whether pace or fillers get in the way.
More directions
Explore another direction
Early access · free
Log your first rep today.
Bring a resume or a job description — or just the role you want. The log starts with your first answer.