Available Captures for Rook
A easy-tier problem at 70% community acceptance, tagged with Array, Matrix, Simulation. Reported in interviews at Block and 0 others.
The Rook problem is a straightforward matrix simulation that comes up in assessments at Block and other companies that care about clean algorithmic thinking. You're given a chessboard and a rook position, and you need to count how many enemy pieces it can capture on its row and column. It's easy to overthink this. The acceptance rate sits at 70%, which means 30% of candidates either misread the problem, miss edge cases, or write inefficient code. If you hit this during a live OA and blank on the setup, StealthCoder surfaces a working solution in seconds while the proctor sees nothing.
Companies that ask "Available Captures for Rook"
Available Captures for Rook 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 by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share.
Get StealthCoderThe trap here is overengineering. You don't need a complex search algorithm. A rook captures anything on its row or column until it hits another piece, so you iterate left, right, up, and down from the rook's position, count captures in each direction, and stop when you hit an obstacle. This is pure simulation. The common mistake is trying to do it in one pass or confusing the directions. The obvious approach works perfectly: four separate loops, each moving in one cardinal direction until you hit a piece or boundary. Most candidates get it right. The few who don't usually either forget that the rook stops at the first obstacle it encounters or write direction logic that's off by one. If you're prepping and this feels too simple, good. That confidence is the right instinct. StealthCoder is your hedge if you somehow blank on the direction logic during the assessment.
Pattern tags
You know the problem.
Make sure you actually pass it.
Available Captures for Rook recycles across companies for a reason. It's easy-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 by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Available Captures for Rook interview FAQ
Is this problem really asked at major companies?+
Block reports having asked it. The acceptance rate of 70% suggests it's filtering for candidates who can implement a straightforward simulation correctly and quickly. It's an easy problem, so it's usually an early-round or qualification screener rather than a hard-stop question.
What's the trick I'm missing?+
There isn't one. That's the lesson. Four loops, one for each direction from the rook. Increment the count when you find an enemy piece, stop when you hit an ally or boundary. Many candidates overthink it and lose time. The trick is recognizing there is no trick.
How do I avoid the 30% of people who get it wrong?+
Test your direction logic carefully. Make sure your loop conditions are correct for each cardinal direction (up, down, left, right). Off-by-one errors on boundary checks are common. Also, re-read the problem statement to confirm what counts as a capture. A few minutes of clarity saves wrong submissions.
Does this problem relate to other matrix problems?+
Yes. It's a warm-up for problems involving matrix traversal and directional movement, like island counting or game-of-life simulations. The Array and Matrix fundamentals here are the same, just applied in four directions instead of one.
What languages is this usually asked in?+
Any. The logic is language-agnostic. The bottleneck isn't syntax, it's getting the direction loops and boundary conditions right in your head. Pick the language you're fastest in and move.
Want the actual problem statement? View "Available Captures for Rook" on LeetCode →