leetcode36. Valid Sudoku
来源:互联网 发布:个人如何注册淘宝店铺 编辑:程序博客网 时间:2024/05/06 09:12
leetcode36. Valid Sudoku
class Solution {public: bool isValidSudoku(vector<vector<char>>& board) { bool result = true; int filled[3][board.size()][board.size()]; for(int i=0;i<board.size();i++){ for(int j = 0;j<board[i].size();j++){ filled[0][i][j] = -1; filled[1][i][j] = -1; filled[2][i][j] = -1; } } for(int i=0;i<board.size();i++){ for(int j = 0;j<board[i].size();j++){ if(board[i][j]!='.'){ if(filled[0][i][board[i][j] - '0' -1] == -1) filled[0][i][board[i][j] - '0' - 1] = i; else{ //cout<<"x"<<filled[2][(i/3 * 3 +j/3)][board[i][j] - '0' -1]<<endl; return false; } if(filled[1][j][board[i][j] - '0' -1] == -1) filled[1][j][board[i][j] - '0' -1] = j; else{ //cout<<"y"<<filled[2][(i/3 * 3 +j/3)][board[i][j] - '0' -1]<<endl; return false; } if(filled[2][(i/3 * 3 +j/3)][board[i][j] - '0' -1] == -1) filled[2][(i/3 * 3 +j/3)][board[i][j] - '0' -1] = ((i%3)*3 +j%3); else{ // cout<<"square"<<filled[2][(i/3 * 3 +j/3)][board[i][j] - '0' -1]<<endl; return false; } } } } return result; }};
阅读全文
0 0
- [LeetCode36]Valid Sudoku
- LeetCode36:Valid Sudoku
- Leetcode36 Valid Sudoku
- LeetCode36. Valid Sudoku
- leetcode36.Valid Sudoku
- leetcode36:valid sudoku
- leetcode36~Valid Sudoku
- leetcode36. Valid Sudoku
- LeetCode36-Valid Sudoku
- leetcode36. Valid Sudoku
- LeetCode36——Valid Sudoku
- LeetCode36——Valid Sudoku
- Valid Sudoku
- Valid Sudoku
- Valid Sudoku
- Valid Sudoku
- Valid Sudoku
- Valid Sudoku
- Linux基本命令
- 1079---BFS
- 数据库中间件mycat测试之二
- lucene query
- PHAsset获得视频URL,遇到的一些问题
- leetcode36. Valid Sudoku
- NC休假、加班、销假合并报表sql
- sos
- pandas 日期处理
- python操作csv文件范例
- hsf入门
- Oracle 学习之窗口函数(over)
- iOS开发之App从点击到启动
- 爬取豆瓣TOP250电影的评分、评价人数、短评等信息,并在其保存在sql数据库中。