当前位置:网站首页>[brush questions] effective Sudoku
[brush questions] effective Sudoku
2022-07-05 16:40:00 【m0_ sixty million six hundred and thirty-one thousand three hun】
One 、 subject
OJ link
Please judge a 9 x 9 Is the Sudoku effective . It only needs According to the following rules , Verify that the numbers you have filled are valid .
Numbers 1-9 Only once in a row .
Numbers 1-9 It can only appear once in each column .
Numbers 1-9 Separated by thick solid lines in each 3x3 Only once in the palace .( Please refer to the example figure )
Be careful :
- An effective Sudoku ( Part has been filled in ) Not necessarily solvable .
- Just follow the above rules , Verify that the numbers you have filled are valid .
- Blank space ‘.’ Express .
source : Power button (LeetCode)
link :https://leetcode.cn/problems/valid-sudoku
Copyright belongs to the network . For commercial reprint, please contact the official authority , Non-commercial reprint please indicate the source .
Two 、 Answer key
2.1 Ideas
2.2 Source code
public boolean isValidSudoku(char[][] board) {
boolean[][] row=new boolean[9][10];
boolean[][] col=new boolean[9][10];
boolean[][] bucket=new boolean[9][10];
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
int bid=3*(i/3)+(j/3);
if(board[i][j]!='.'){
int num=board[i][j]-'0';
if(row[i][num]||col[j][num]||bucket[bid][num]){
return false;
}
row[i][num]=true;
col[j][num]=true;
bucket[bid][num]=true;
}
}
}
return true;
}
边栏推荐
- One click installation script enables rapid deployment of graylog server 4.2.10 stand-alone version
- 有序链表集合求交集 方法 总结
- The memory of a Zhang
- 漫画:什么是八皇后问题?
- Convert obj set to entity set
- DeSci:去中心化科学是Web3.0的新趋势?
- Using graylog alarm function to realize the regular work reminder of nail group robots
- 【刷题篇】鹅厂文化衫问题
- Mongodb getting started Tutorial Part 04 mongodb client
- Solve the Hanoi Tower problem [modified version]
猜你喜欢
Spring Festival Limited "forget trouble in the year of the ox" gift bag waiting for you to pick it up~
Intel 13th generation Raptor Lake processor information exposure: more cores, larger cache
Win11提示无法安全下载软件怎么办?Win11无法安全下载软件
Reduce the cost by 40%! Container practice of redis multi tenant cluster
清晰还原31年前现场,火山引擎超清修复Beyond经典演唱会
Win11 prompt: what if the software cannot be downloaded safely? Win11 cannot download software safely
ES6深入—async 函数 与 Symbol 类型
Explain in detail the functions and underlying implementation logic of the groups sets statement in SQL
Benji Banas membership pass holders' second quarter reward activities update list
Single merchant v4.4 has the same original intention and strength!
随机推荐
Android 隐私沙盒开发者预览版 3: 隐私安全和个性化体验全都要
The difference between searching forward index and inverted index
CISP-PTE之SQL注入(二次注入的应用)
2020-2022两周年创作纪念日
单商户 V4.4,初心未变,实力依旧!
为季前卡牌游戏 MotoGP Ignition Champions 做好准备!
The list set is summed up according to a certain attribute of the object, the maximum value, etc
Desci: is decentralized science the new trend of Web3.0?
阿掌的怀念
漫画:什么是分布式事务?
Raspberry pie 4B installation pytorch1.11
自己要有自己的坚持
利用GrayLog告警功能实现钉钉群机器人定时工作提醒
[deep learning] [original] let yolov6-0.1.0 support the txt reading dataset mode of yolov5
Convert obj set to entity set
Win11提示无法安全下载软件怎么办?Win11无法安全下载软件
Reduce the cost by 40%! Container practice of redis multi tenant cluster
yarn 常用命令
How was the middle table destroyed?
中间表是如何被消灭的?