Library
Cracking the PM Interview: How to Land a Product Manager Job in Technology · 3 of 11
Cracking the PM Interview: How to Land a Product Manager Job in Technology
Entrepreneurship MEDIUM

Technical and Coding Questions

coding algorithms data-structures technical-interview

Problem This Solves

Some PM roles at technical companies include coding or algorithm questions. Candidates who dive straight into code or freeze when stuck fail not because of knowledge gaps, but because they lack a structured process. This reference addresses how to approach these questions methodically and what technical concepts to know at the PM level.

Key Principle

Coding is Step 5 of 6, not Step 1. The interviewer is evaluating structured thinking, communication, and persistence — not whether you produce a perfect solution. "Evaluation of your performance is not about whether you got the problem 'right' or not."

Good Examples

Six-step approach applied correctly:

  1. Clarify — ask questions, repeat the problem back in your own words
  2. Whiteboard — draw a specific, non-edge-case example (e.g., {1, 5, 8, 9} not just "array a")
  3. Talk out loud — brainstorm aloud; brute force is a valid starting point
  4. Think critically — state Big O, look for failure cases, ask if you can do better
  5. Code slowly — write pseudocode first if needed; understand every line
  6. Test and fix — walk through edge cases; expect and fix bugs calmly

Hashtable optimization (subset check):

  • Brute force: O(a*b) — inner loop searches the second collection for each element
  • Optimized: pre-load the second collection into a hashtable; lookup becomes O(1), total O(a+b)

Maximum subarray — O(N) single pass:

  • Reset the running sum to zero whenever it goes negative; a negative prefix can only hurt any extension
  • This converts an O(N^3) naive solution through O(N^2) to O(N)

Celebrity problem — O(N) two-pass:

  • Brute force O(N^2); key insight: given any two candidates, one can always be eliminated in O(1)
  • If knows(x, y) = true, x is eliminated; if false, y is eliminated
  • One pass finds a single candidate; a second pass verifies

Bad Examples

  • Starting to write code the moment the problem is stated — skips clarification and examples
  • Writing O(2N) instead of O(N) — "this is not a 'more precise' answer than O(N); it's only a confusing one"
  • Ignoring the base case in a recursive function — without it, "the function would run forever"
  • Giving up when stuck — interviewers want to see persistence; "push your way through problems"

Key Quotes

  • "Observe that the coding part is Step 5, not Step 1. Do not just get up to the whiteboard and start coding once you hear a problem."
  • "There is no shame at all in starting with a brute force solution or a naive solution. It gives you a good starting point from which you can optimize."
  • "Remember: if you're struggling to solve a problem, that's normal. These problems are designed to be difficult."
  • "Big O is not an expression of how many seconds something actually takes. It expresses how the time scales as the size of the input gets longer and longer."
  • "The base case (or terminating condition) is extremely important. Without it, the function would run forever."
  • "Don't be discouraged when you struggle, and don't give up. Interviewers want to see that you'll push your way through problems."

Rules of Thumb

Big O:

  • Drop all constants and lower-order terms: O(2N) = O(N); O(N^2 + N) = O(N^2)
  • If something halves repeatedly, it is O(log N) — applies to binary search and balanced BST operations
  • When two independent variables affect runtime, keep both: O(M*W) not O(N^2)

Data structures at a glance:

  • Array: O(1) indexed lookup, O(N) search by value
  • Hashtable: O(1) insert and lookup (average); go-to for converting inner-loop search to O(1)
  • Binary Search Tree (balanced): O(log N) insert and find
  • Stack (LIFO): O(1) push/pop
  • Queue (FIFO): O(1) enqueue/dequeue; required data structure for BFS

Sorting algorithms:

  • Merge sort: O(n log n) average and worst
  • Quick sort: O(n log n) average, O(n^2) worst (bad pivot)
  • Insertion sort / Bubble sort: O(N) best, O(N^2) average and worst

Algorithm strategies when stuck:

  1. Use a specific example on the whiteboard
  2. State brute force first, then identify the bottleneck step
  3. Solve for base case (n=0, 1, 2) and look for a pattern
  4. Think about similar problems you have seen
  5. Simplify by relaxing one constraint; see if that version is solvable
  6. Write down key observations as you discover them

Graph/tree traversal:

  • BFS: use a queue; explores wide before deep; finds shortest path
  • DFS: use recursion; explores deep before wide
  • In graphs (not trees), mark nodes visited to prevent infinite loops from cycles

Related References