Check if Every Row and Column Contains All Numbers
A easy-tier problem at 53% community acceptance, tagged with Array, Hash Table, Matrix. Reported in interviews at Instacart and 2 others.
You're scanning a matrix and need to verify that every row and every column contains all numbers from 1 to n. Instacart, Karat, and Indeed have asked this. It's easy difficulty with just over 52% acceptance, which means most people who see it will solve it, but the 48% failure rate suggests careless implementations slip through. The trick isn't algorithmic complexity; it's cleanly validating two dimensions without redundant loops. If this lands in your assessment and you blank on the structure, StealthCoder runs invisibly during screen share and surfaces a working solution in seconds.
Companies that ask "Check if Every Row and Column Contains All Numbers"
Check if Every Row and Column Contains All Numbers 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 Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code.
Get StealthCoderThe pattern here is straightforward: iterate through all rows, checking that each contains the complete set {1, 2,..., n}, then do the same for columns. Most candidates default to nested loops with sets or sorting, which works but can feel clunky if you're rushing. The real pitfall is forgetting one dimension entirely or mixing up row/column indexing. Some jump to a single-pass approach and overcomplicate it. The honest path is two clean phases: validate rows, then validate columns. Use a set or range check for each. If you see this during the live OA and freeze on the two-loop structure, StealthCoder bridges that gap and gives you working code instantly, no proctor visibility.
Pattern tags
You know the problem.
Make sure you actually pass it.
Check if Every Row and Column Contains All Numbers 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 Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Check if Every Row and Column Contains All Numbers interview FAQ
Is this really just checking sets twice?+
Yes, at core it's two separate validation passes. Build a set of numbers 1 to n, then iterate rows and check each row equals that set. Repeat for columns. The easy part tricks people into over-engineering it. Keep it simple and direct.
How does this connect to the Matrix and Hash Table topics?+
Matrix is the data structure; you're iterating over rows and columns. Hash Table covers the set-based validation. Use a set to store expected numbers and check membership, or use a set of row/column elements and compare to the full range.
What if the matrix isn't square?+
A non-square matrix can't satisfy the constraint that every row and column contains all numbers 1 to n. Usually these problems assume n x n input. Check the problem statement; if non-square is possible, return false early.
Can I do this in a single pass?+
Theoretically yes, but it's messier. You'd need to track which numbers appear in each row and column simultaneously, and defer validation until the end. Two clean passes are faster to code and less error-prone under interview pressure.
Why is acceptance only 52% if it's easy difficulty?+
Easy doesn't mean trivial. Off-by-one errors in indexing, forgetting to check both rows and columns, or using the wrong validation logic trip candidates up. Speed and careless mistakes account for the gap between difficulty rating and pass rate.
Want the actual problem statement? View "Check if Every Row and Column Contains All Numbers" on LeetCode →