方法一
思路:brute force
时间复杂度:O(n^2)
1 | // Runtime: 96 ms, faster than 28.80% of JavaScript online submissions for Valid Sudoku. |
方法二(Recommend)
思路:利用set缓存每一步的结果
时间复杂度:O(n^2),实际上比方法一通用、高效很多
1 | // Runtime: 100 ms, faster than 25.57% of JavaScript online submissions for Valid Sudoku. |
test cases:
1 | test("test1", () => { |