Problem
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 '.'.
Idea
- Each row must have the numbers 1-9 occuring just once.
- Each column must have the numbers 1-9 occuring just once.
- And the numbers 1-9 must occur just once in each of the 9 sub-boxes of the grid.
- 先检查行,再检查列,再检查每个3*3的cube
- 判断是否重复的方法是讲一行或者一列或者1个3*3放入vector中。 然后再存入hash_map中,利用hash_map的find()!=hash_map.end()来判断是否有重复的 复杂度O(n)
Notes
- How to insert hash map
- How to find an element in the hash_map
- How to push/pop an element by vector
Solution
No comments:
Post a Comment