Technical questions
Coding and technical rounds in PM interviews
In this lesson9 sections
An unofficial lesson drawing on the methods in the Coding Questions chapter of Cracking the PM Interview by Gayle Laakmann McDowell and Jackie Bavaro (2014). PracHub is not affiliated with the authors or publisher. Buy the book
A technical round in a PM interview checks whether you can think through a problem the way your engineers will: in clear steps, with an eye on cost. Sometimes that means writing a short function. More often it means explaining an approach, a system or a trade-off out loud. This lesson covers who still gets asked to code, then works one problem from the first question to the last test.
The problem we'll carry through:
"Our servers have maintenance windows, each with a start time and an end time. Some of them overlap. Write a function that merges them, so the on-call calendar shows each busy period once."
Will you have to write code?
Probably not. Most PM loops today have no live-coding round. Where a technical round exists, it more often asks you to explain how a system works, talk through a design and its trade-offs, or write SQL. Some now have you build a small prototype with an AI coding tool and defend it; see our PM vibe coding interview guide.
Live coding still turns up, mainly in technical PM roles. Where it does, a recent computer science graduate or former engineer is likelier to be asked for code that would run. If that's you, practise as you'll be tested: two or three small problems a week, 25 minutes each, talking aloud in a plain doc, with a list of what tripped you to review the week before, rather than a textbook.
For everyone, the bar sits below an engineer's. Many interviewers accept pseudocode: steps written as code-like lines that wouldn't compile.
If you've never coded, you'll likely skip the code but may still be asked how you'd solve a problem step by step, or how a product you use works underneath. Either way, ask the recruiter what the technical round covers and whether code is expected.
Some interviewers simply ask whether you can code. To practise answering it, try Explaining Your Coding Skills and Technical Depth in a Product Manager Interview in under a minute.
What the interviewer is listening for
Underneath every format, the question is whether engineers will find you easy to work with on technical decisions. They listen for whether you break a vague problem into steps someone could build, and whether you know the everyday data structures well enough to pick one, such as a list you walk through or a hash map you look things up in. Our lesson on big O and data structures for PMs covers those, and technical PM interview questions covers systems and APIs.
They also listen for trade-offs put in terms an engineer respects, even when nobody asks for code; engineering-heavy teams weigh this most. The on-call calendar could merge windows when one is added and store the result, so views are quick, or merge on every view, so nothing goes stale but each view pays. At fifty views per edit, I'd store it. The same choice comes up with caching, and with AI features: summarise a ticket once when it closes, or on every view at a cost each time?
A slow answer, and the facts that would change it
Open with the simplest answer that works, before you ask anything:
"So I get a list of windows, each a start and an end, and I return a shorter list where any that overlap become one. The simplest thing that works: compare every pair, merge any two that overlap, and repeat full passes until one merges nothing. That's about n squared per pass and up to n passes, so roughly n cubed. Slow, but correct. Before I improve it, a few questions."
A baseline does two jobs. The interviewer knows you can reach a working answer, and you can see which facts would change it. Those facts are your questions:
Is the list sorted by start time, or in the order it was reported?
If one window ends at 11:00 and the next starts at 11:00, is that one busy period or two?
May I reorder or change the list I'm given, or does the caller still need it as it was?
Do I get the whole list, or only a calendar service that lets me add a window and read one day?
Roughly how many windows: a few dozen a week, or millions across the fleet?
The interface matters: with only add and read calls, you'd merge each window in as it arrives.
Say the interviewer answers: unsorted, touching windows merge, reorder freely, the whole list, a few thousand windows.
Sort first, then one pass
The baseline spends nearly all its time comparing windows that can't overlap, such as ones at 09:00 and 19:00. To see which comparisons you could skip, write an example in the shared doc, or on a whiteboard if the round is in person, and merge it by hand, out loud. Make it as messy as real data: out of order, with an overlap, a chain and a gap.
A 13:00-15:00 B 09:00-10:00 C 14:00-16:30
D 09:30-11:00 E 19:00-20:00 F 16:00-17:00
Merging these, you'll put them in time order unprompted: B, D, A, C, F, E. B and D give 09:00 to 11:00. A starts after 11:00, so that period is finished. A, C and F chain into 13:00 to 17:00. E stands alone. Three busy periods.
Going quiet for minutes, or saying "I haven't seen this one" and waiting, reads as someone who stalls when work gets hard, so keep trying ideas out loud, weak ones included.
Putting them in time order is the algorithm showing itself. Once the windows are in start order, a window can only overlap the period you're building. So sort by start and walk the list once: if the next window starts at or before the current period's end, extend the period; if not, close it and start a new one. Typed in start order, the example would have hidden that ordering was the step that mattered.
Now the answers pay off. Sorting is O(n log n) and the walk is O(n), so O(n log n) in all, against roughly n cubed for the baseline. Had the list arrived sorted, the walk alone would be O(n), which is why the first question was worth asking. Permission to reorder lets you sort the caller's list in place rather than build a sorted copy. An answer that leaves a given fact unused is probably not the one the interviewer had in mind.
To practise, try Add one to a non-negative integer stored as an array of decimal digits and work a few cases on paper before writing anything.
A forced value removes a search
Sorting fixed the windows baseline because order told you which comparisons to skip. Other slow answers lose their time to searching. Say you need two cron jobs whose run times add up to exactly 60 minutes. Checking every pair is O(n²). But a 25-minute job can only pair with a 35-minute one, so look the partner up: walk the jobs once, checking a hash map for each job's partner before adding the job, and it's O(n). More generally, give each item a computed key so that items which belong together share a bucket and one pass finds them all, as our big O lesson does with duplicate listings. (Sorting by run time and stopping once a sum passes 60 also helps, but less.) Running totals and other tricks are in making a slow solution fast.
To practise, try Word Compression Algorithm: say what the simplest version costs, then which step you'd change.
The merge answer, without code
If you've never coded, your answer ends here, in plain steps:
"I'd put the windows in order of start time and take the first as the current busy period. For each window after it, if it starts at or before the moment the current period ends, I stretch the period to whichever end is later. If it starts later, that period is done: I write it down, and this window becomes the current one. At the end I write down the last period. Sorting is the slowest part; after that I look at each window once."
Where this function breaks
In Python, a first draft of the sort and the walk:
def merge_windows(windows):
windows.sort() # by start, in place: we may reorder
merged = [list(windows[0])]
for i in range(1, len(windows)):
start, end = windows[i]
current = merged[-1]
if start <= current[1]: # overlaps or touches
current[1] = end
else:
merged.append([start, end])
return merged
The draft needed only a list and the built-in sort, and most PM rounds assume about that much: look a value up in a hash map, call a sort and know it costs O(n log n), find an item in a sorted list by halving the range. Nobody minds a forgotten method name if the code would plausibly work in a language you know, without clever syntax. Questions that hinge on a famous named algorithm are rare for PMs: reciting one shows you studied, while working one out live shows how you'd reason with your engineers.
Walk the six windows through it, noting merged after each one the code handles:
B 09:00-10:00 [09:00-10:00]
D 09:30-11:00 [09:00-11:00]
A 13:00-15:00 [09:00-11:00] [13:00-15:00]
C 14:00-16:30 [09:00-11:00] [13:00-16:30]
F 16:00-17:00 [09:00-11:00] [13:00-17:00]
E 19:00-20:00 [09:00-11:00] [13:00-17:00] [19:00-20:00]
Three periods, matching the hand merge. But no window here sits inside another, so the trace misses the worst bug. Two of these inputs break it:
An empty list:
windows[0]fails, since the code assumes at least one window. Return an empty list straight away.One window: the loop never runs and the window comes back unchanged.
A window inside another, 13:00 to 17:00 then 14:00 to 15:00: the draft sets the end to 15:00 and shrinks the period. It assumed a window that starts later also ends later;
current[1] = max(current[1], end)keeps the later end.Two touching windows, 10:00 to 11:00 then 11:00 to 12:00: the
<=merges them, as the interviewer asked.The last period: versions that keep the current period in its own variable often forget to add it after the loop, and 19:00 to 20:00 quietly vanishes.
Most slips live at boundaries like these: <= against <, the last item, a midpoint, a +1 that may not belong. If you move an index yourself inside a loop, confirm it changes on every path, or the loop never ends. For a harder problem taken through a full round, see working an unseen problem.
To practise finding the inputs that break an idea, try Break a Palindrome Algorithm.
What the interviewer was writing down
About five minutes in, the first note: working baseline. You get to something that works before you polish it.
Next: found the sort by hand. Nobody asked for time order; merging the windows out loud needed it. You reason from the case in front of you, as a new problem at work needs.
After the draft: caught the nested-window bug with edge cases. You found the shrinking period yourself, so your engineers won't have to check everything you write.
Then you leave for the next interview of the loop, not knowing how this one went. Treat a round that felt rough as no information, and walk in as if it went fine.
Questions with no single right algorithm
Some PM technical rounds skip code and ask you to design the logic for something, such as a program that plays a word game or the rules an elevator follows. With no answer to find, the interviewer grades your choices: say what the program is trying to achieve, and name what each rule you add costs against a plain version that already works. More technical questions for PMs, including concept explanations, sit under software engineering fundamentals for PMs.
To practise, answer Letter-Guessing Strategy for a Program That Plays Hangman and Controller Algorithm for a Single-Rider Pandemic Elevator out loud, about 20 minutes each.
Letter-Guessing Strategy for a Program That Plays Hangman
A technical question for Google product manager candidates: explain how a program could play Hangman as the guesser.
Controller Algorithm for a Single-Rider Pandemic Elevator
Design the dispatch logic for an elevator when a pandemic makes riders avoid shared enclosed space.