Watch a full mock coding interview with a software engineer from Intel as they work through two classic algorithm problems in real time. This 52-minute coding interview covers Lowest Common Ancestor in a Binary Search Tree and the Walls and Gates matrix distance problem — two questions that appear frequently in FAANG and top-tier tech interviews.
The interview starts with a warm-up problem where the candidate explains the difference between solving LCA on a generic binary tree versus a binary search tree, leveraging BST properties to achieve O(log n) time. The main problem is a 2D matrix challenge: given a grid of zeros, walls, and guards, find the shortest distance from every open cell to the nearest guard. The candidate works through a recursive DFS approach in C++, debugging edge cases around visited cells and minimum distance tracking. The interviewer then walks through why BFS from all guard cells simultaneously is the optimal approach, reducing time complexity from O(G * N * M) to O(N * M).
0:00 Introduction and interview format
0:08 Problem 1: Lowest Common Ancestor in a BST
1:28 BST optimization vs binary tree approach
2:06 Problem 2: 2D matrix — shortest distance to nearest guard
5:33 Discussing approach and initial pseudocode
6:37 Interviewer hints at improving brute force
12:06 Runtime complexity analysis
15:33 Starting code implementation in C++
19:01 Coding the recursive DFS solution
32:52 Debugging visited cells and minimum distance logic
42:00 Testing and fixing edge cases
47:47 Interviewer feedback and wrap-up
49:11 Discussion: why BFS is the optimal approach
52:12 Closing Q&A
Problems covered:
LeetCode 235 — Lowest Common Ancestor of a BST: https://leetcode.com/problems/lowest-...
LeetCode 286 — Walls and Gates: https://leetcode.com/problems/walls-a...