Search a 2D Matrix II
A medium-tier problem at 55% community acceptance, tagged with Array, Binary Search, Divide and Conquer. Reported in interviews at Whatnot and 10 others.
Search a 2D Matrix II is a medium-difficulty matrix problem that appears in OAs at Google, ByteDance, PayPal, Citadel, and other tier-1 shops. The acceptance rate sits around 55%, which means half the candidates who attempt it fail. You get a 2D matrix with specific row and column ordering properties, and you need to search for a target value efficiently. The naive approach (linear scan) works but wastes time. The trick is spotting the matrix structure and using it to eliminate entire rows or columns per comparison. If you blank on the pattern during your live assessment, StealthCoder surfaces a working solution in seconds, invisible to the proctor.
Companies that ask "Search a 2D Matrix II"
Search a 2D Matrix II is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround.
Get StealthCoderThe key insight is that you can't use standard binary search on a whole 2D grid, but you can use a greedy pointer-walking strategy that treats the matrix geometry as an advantage. Start at either the top-right or bottom-left corner. From there, each comparison lets you eliminate one entire row or column, giving you O(m+n) time instead of O(m*n). Most candidates either try to binary search the flattened array (inefficient and wrong for this problem's constraints) or iterate naively through every cell. The actual pattern requires recognizing that the matrix structure creates a monotonic path. Divide and Conquer also works but is slower. When you hit this in a live OA and can't recall the corner-start trick, StealthCoder runs invisibly and gives you the optimized solution so you move on.
Pattern tags
You know the problem.
Make sure you actually pass it.
Search a 2D Matrix II recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Search a 2D Matrix II interview FAQ
Is this problem actually asked at FAANG?+
Yes. Google, ByteDance, PayPal, and Citadel are all in the reported list. It's a popular medium that screens for pattern recognition and matrix intuition. The 55% acceptance rate reflects that many candidates either don't know the trick or implement it slowly.
What's the trick I'm supposed to see?+
The matrix rows are sorted left-to-right and columns are sorted top-to-bottom. You start at a corner (top-right or bottom-left) and walk inward. Each comparison eliminates a row or column. This gives O(m+n) time, not O(m*n). It's counterintuitive because the structure isn't a standard sorted array.
Can I just binary search it?+
You can binary search each row individually, but that's O(m log n), which is slower than the corner-walk O(m+n). Binary search on the flattened array doesn't work because the 2D matrix isn't a 1D sorted array. The problem design punishes brute force and rewards spotting the geometry.
How does this relate to the Array and Matrix topics?+
It combines both. You're working with a 2D array structure (Matrix) and using pointer techniques and traversal logic (Array). Divide and Conquer is also tagged because some solutions use a recursive quad-split approach, though it's suboptimal.
What happens if I time out on this in my OA?+
If you implement a naive O(m*n) scan or get stuck on binary search logic, you'll either timeout or get partial credit. That's when StealthCoder is your safety net. It reads the problem and gives you the correct O(m+n) solution in real time, invisible to the proctor.
Want the actual problem statement? View "Search a 2D Matrix II" on LeetCode →