Answer: Visa OA Question 2024 May | Matrix & HashSet | on-campus
Answer · Posted Jun 2026
Solution: Valid Sudoku — HashSet per Row, Column, and Box Approach We make a single pass through the 9x9 board. For each filled cell, we check three conditions simultaneously using HashSets: Row check: Has this digit appeared in this row before? Column check: Has this digit appeared in this column before? Box check: Has this digit appeared in this 3x3 sub-box before? The box index is computed as (r/3)*3 + (c/3). If any duplicate is found in any of the ...
The full answer & interview discussion are available to premium members.
Log in Create a free account