leetcode刷题,总结,记录,备忘 36
来源:互联网 发布:淘宝客qq群推广软件 编辑:程序博客网 时间:2024/05/17 12:53
leetcode36Valid Sudoku
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.
Subscribe to see which companies asked this question
class Solution {public: bool isValidSudoku(vector<vector<char>>& board) { vector<set<char> > vsr(9, set<char>()); vector<set<char> > vsc(9, set<char>()); vector<set<char> > vsm(9, set<char>()); for (int i = 0; i < board.size(); ++i) { for (int j = 0; j < board[i].size(); ++j) { char val = board[i][j]; if (val == '.') { continue; } else { pair<set<char>::iterator, bool> br = vsr[i].insert(val); pair<set<char>::iterator, bool> bc = vsc[j].insert(val); pair<set<char>::iterator, bool> bm = vsm[i/3*3 + j/3].insert(val); if (!br.second || !bc.second || !bm.second) { return false; } } } } return true; }};
0 0
- leetcode刷题,总结,记录,备忘 36
- leetcode刷题。总结,记录,备忘 104
- leetcode刷题。总结,记录,备忘 100
- leetcode刷题。总结,记录,备忘 191
- leetcode刷题。总结,记录,备忘。168
- leetcode刷题, 总结,记录,备忘 171
- leetcode刷题 ,总结,记录,备忘。144
- leetcode刷题,总结,记录, 备忘 141
- leetcode刷题,总结,记录,备忘。116
- leetcode刷题,总结,记录,备忘。96
- leetcode刷题。记录,总结,备忘。217
- leetcode 刷题, 总结,记录,备忘 35
- leetcode刷题,总结,记录,备忘 226
- leetcode刷题,总结,记录,备忘 169
- leetcode刷题,总结,记录,备忘137
- leetcode刷题,总结,记录,备忘83
- leetcode刷题,总结,记录,备忘70
- leetcode刷题,总结,记录,备忘 108
- Web-page Classification through Summarization,2004
- ios解决http上传乱码问题
- [VB](更正:此前理解错误,static在整个程序运行中保留原值,每次调用过程static都应该保留上次原值,答案懒得改了)常见小程序积累
- 早期Swift中Cocos2D初始化代码的重构
- Struts2中result的type属性;值栈
- leetcode刷题,总结,记录,备忘 36
- CentOS下使用yum搭建LAMP环境
- PHP面向对象编程--继承(重写(多态)、封装、可见性)
- 个人博客开发手记(一)——初步设想
- HTTP协议格式
- OGNL
- 85 stl(十二)
- 设计模式之工厂模式
- Android Hugo