Coding Interview Question Generator
Get real coding interview questions by topic and difficulty, with hints, complexity, and follow-ups
- Question
- Capture all regions of O surrounded by X on a board, leaving regions connected to the border.
- Topic
- graphs
- Difficulty
- medium
- Approach hint
- DFS or BFS from every border O to mark safe cells, then flip the rest
- Time complexity
- O(m*n)
- Space complexity
- O(m*n)
- Follow-up
- how would union-find with a virtual border node solve it?
- Question
- Find the contiguous subarray with the largest sum and return that sum.
- Topic
- arrays
- Difficulty
- medium
- Approach hint
- Kadane's algorithm: keep the best sum ending at the current index and reset when it drops below the current element
- Time complexity
- O(n)
- Space complexity
- O(1)
- Follow-up
- how would you also return the start and end indices of that subarray?
- Question
- Generate all possible subsets of a set of distinct integers.
- Topic
- recursion
- Difficulty
- medium
- Approach hint
- for each element, recurse both including and excluding it, or build the result iteratively by doubling it
- Time complexity
- O(n * 2^n)
- Space complexity
- O(n) call stack
- Follow-up
- how would the approach change if the input contained duplicate elements?
Generated 3 items
See 3 examples
- Example 1
Question: Capture all regions of O surrounded by X on a board, leaving regions connected to the border. Topic: graphs Difficulty: medium Approach hint: DFS or BFS from every border O to mark safe cells, then flip the rest Time complexity: O(m*n) Space complexity: O(m*n) Follow-up: how would union-find with a virtual border node solve it? Question: Find the contiguous subarray with the largest sum and return that sum. Topic: arrays Difficulty: medium Approach hint: Kadane's algorithm: keep the best sum ending at the current index and reset when it drops below the current element Time complexity: O(n) Space complexity: O(1) Follow-up: how would you also return the start and end indices of that subarray? Question: Generate all possible subsets of a set of distinct integers. Topic: recursion Difficulty: medium Approach hint: for each element, recurse both including and excluding it, or build the result iteratively by doubling it Time complexity: O(n * 2^n) Space complexity: O(n) call stack Follow-up: how would the approach change if the input contained duplicate elements?
- Example 2
Question: Find the lowest common ancestor of two nodes in a binary search tree. Topic: trees Difficulty: medium Approach hint: walk down from the root, going left if both values are smaller and right if both are larger, stopping when they split Time complexity: O(h) Space complexity: O(1) Follow-up: how does this differ from the general binary tree version? Question: Find the minimum path sum from the top to the bottom of a triangle-shaped array of numbers. Topic: dynamic programming Difficulty: medium Approach hint: work bottom-up so dp[j] = triangle[i][j] + min(dp[j], dp[j+1]) using the row below Time complexity: O(n^2) Space complexity: O(n) Follow-up: how would you solve it top-down instead, and why is bottom-up usually cleaner here? Question: Find the shortest path in a binary grid from the top-left to the bottom-right cell, moving in eight directions. Topic: graphs Difficulty: medium Approach hint: BFS from the start, marking visited cells and counting levels Time complexity: O(n^2) Space complexity: O(n^2) Follow-up: how would A* search speed this up?
- Example 3
Question: Group an array of strings into clusters where each cluster contains anagrams of each other. Topic: strings, hash tables Difficulty: medium Approach hint: use a canonical signature, like the sorted string, as a hash map key Time complexity: O(n*k log k) Space complexity: O(n*k) Follow-up: how would you generate the signature without sorting, to speed things up? Question: Connect each node in a binary tree to its next right neighbor at the same level. Topic: trees Difficulty: medium Approach hint: use the already-established next pointers from the level above to traverse the current level without a queue Time complexity: O(n) Space complexity: O(1) extra Follow-up: does this same O(1)-space approach still work if the tree is not a perfect binary tree? Question: Find the maximum sum of a subarray after deleting at most one element. Topic: dynamic programming Difficulty: medium Approach hint: track two DP values: best sum ending here with no deletion and with one deletion used Time complexity: O(n) Space complexity: O(1) Follow-up: how would you generalize to at most k deletions?
About this generator
Preparing for a coding interview usually means either scrolling through a massive, unsorted problem list or drilling the same five overexposed questions everyone else already knows. A coding interview question generator narrows that down instantly: pick a topic like arrays, trees, graphs, or dynamic programming, set a difficulty, and get back real, LeetCode-style classic problems pulled from a curated pool — not invented busywork. Each question comes with more than just a prompt. You get the topic tags, a difficulty label, an approach hint pointing at the technique without giving away the full solution, the expected time and space complexity, and a follow-up question of the kind an interviewer actually asks once you've solved the base problem. That structure mirrors a real technical interview far more closely than a bare question list, making it useful for self-quizzing, building a study plan around weak topics, or running a quick mock-interview session with a study partner where one person reads the question and the other reasons through the hint and complexity out loud.
How to use
- Choose a Topic — a specific data structure or algorithm area, or 'any' for a mixed set.
- Set the Difficulty to easy, medium, or hard depending on where you're focusing your practice.
- Set How Many to the number of questions you want generated in this batch, from 1 to 10.
- Click Generate to produce a list of full questions, each with a hint, complexity, and follow-up.
- Attempt each question before reading the hint, then check your complexity analysis against the one shown.
- Use the follow-up line to push further once you've solved the base problem, just like a real interviewer would.
Use Cases
- •A new-grad engineer drilling one topic at a time — arrays this week, graphs next — before a set of onsite interviews
- •A bootcamp instructor pulling five medium-difficulty questions to build a timed practice quiz for students
- •A study group running a mock interview where one person reads the generated question aloud and the other whiteboards it
- •An engineer switching specialties brushing up specifically on dynamic programming and graphs before an internal transfer interview
- •A hiring manager sourcing warm-up questions for a phone screen instead of reusing the same three questions every time
Tips
- →Cover the hint and follow-up first, solve the base question cold, then reveal them to check your approach.
- →Rotate through all nine topics over a week rather than only practicing your strongest area.
- →Say your time and space complexity out loud before checking the answer — that habit matters as much in a real interview as solving the problem.
- →Use the follow-up question as a second round once you've solved the base problem, since interviewers rarely stop at the first solution.
- →Pair up with a study partner and take turns reading the generated question aloud instead of just reading it silently.
- →Set difficulty to 'hard' only after you can solve 'medium' questions in your target topic within 20 to 25 minutes.
FAQ
how do I practice just one topic like dynamic programming
Set the Topic dropdown to 'dynamic-programming' and pick your difficulty level, then generate. Every question returned will be pulled specifically from that topic's pool, so you can drill one weak area repeatedly without wading through arrays or string questions you already know.
are these real interview questions or made up
They're drawn from a curated pool of verified, LeetCode-style classic problems — the kind that show up repeatedly across real technical interviews at tech companies. Nothing is invented on the fly; each entry includes the actual problem statement, a genuine approach hint, and correct complexity analysis.
what does the "any" topic option do
Setting Topic to 'any' pulls from every topic's pool at the chosen difficulty level, so you get a mixed set spanning arrays, trees, graphs, dynamic programming, and more. It's useful for a general warm-up quiz or when you don't yet know which topic to focus on.
Do the hints give away the full solution?
No — each approach hint names the core technique or data structure (a hash map, two pointers, a monotonic stack) without walking through the full implementation. You still have to figure out how to apply it, which keeps the practice closer to a real interview than reading a worked solution.
Can I generate more than one question at a time?
Yes — set How Many to any value from 1 to 10 and generate that many questions in one batch, all matching your chosen topic and difficulty. This is convenient for building a timed practice set instead of generating one question at a time.
You might also like
Popular tools from other categories that share themes with this one.