36. Valid 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.
关于数独的简介:
There are just 3 rules to Sudoku.
1.Each row must have the numbers 1-9 occuring just once.

2.Each column must have the numbers 1-9 occuring just once.

3.And the numbers 1-9 must occur just once in each of the 9 sub-boxes of the grid.

题目大意:
判断一个给定的二维数组是否是一个合法的数独矩阵。
思路:
采用set这一容器,来进行去重。
1.判断每一行是否合法。
2.判断每一列是否合法。
3.判断每一个九宫格是否合法。
代码如下:
class Solution {
public:
bool isValidSudoku(vector>& board)
{
set mySet;
//1.判断每一行是否合法
for (int row = 0; row < 9; row++)
{
//cout<<"检测行:"<2016-08-13 12:21:54
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
标题名称:leetCode36.ValidSudoku(数独)哈希-创新互联
本文URL:http://www.yingshanweb.cn/article/ddsijh.html
|
其他资讯
- python判断字符串是否包含某些字符的方法-创新互联
- python脚本监控logstash进程并邮件告警的实现方法-创新互联
- 抖音代运营套餐价格表大介绍,选择合适的抖音代运营介绍方法
- linux查看gcc命令,linux查询gcc版本及相关的命令
- 怎么判断学校域名 怎么查校园网域名
- “云+屏”牵引“极简工作”新时代新华三发布H3CWorkspace数字工作空间
- windowslive是干什么用的,可以删掉不?windowslive服务器
- 怎么样找到一个好的电商平台给其供货?(怎么经营好电商项目?)
- Linux中VD和SD的区别及其作用简介 (linux vd 和 sd)
- 手机为什么打不开lnk文件


咨询
建站咨询
