// Source : https://oj.leetcode.com/problems/valid-sudoku/ // Author : Hao Chen // Date : 2014-07-17 /********************************************************************************** * * Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. * * The Sudoku board could be partially filled, where empty cells are filled with the character '.'. * * A partially filled sudoku which is valid. * * Note: * > A valid Sudoku board (partially filled) is not necessarily solvable. * Only the filled cells need to be validated. * * **********************************************************************************/ class Solution { public: bool isValidSudoku(vector > &board) { const int cnt = 9; bool row_mask[cnt][cnt] = {false}; bool col_mask[cnt][cnt] = {false}; bool area_mask[cnt][cnt] = {false}; //check each rows and cols for(int r=0; r