当前位置:网站首页>[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;
}
边栏推荐
- Today's sleep quality record 79 points
- 求解汉诺塔问题【修改版】
- Basic introduction to the control of the row component displaying its children in the horizontal array (tutorial includes source code)
- Raspberry pie 4B installation pytorch1.11
- 程序员如何提升自己的格局?
- 国泰君安网上开户安全吗
- 企业级备份软件Veritas NetBackup(NBU) 8.1.1服务端的安装部署
- 详解SQL中Groupings Sets 语句的功能和底层实现逻辑
- 效果编辑器新版上线!3D渲染、加标注、设置动画,这次一个编辑器就够了
- 10分钟帮你搞定Zabbix监控平台告警推送到钉钉群
猜你喜欢

Research and development efficiency measurement index composition and efficiency measurement methodology

OneForAll安装使用

数据访问 - EntityFramework集成

Benji Banas membership pass holders' second quarter reward activities update list

Single merchant v4.4 has the same original intention and strength!

如何将mysql卸载干净

有序链表集合求交集 方法 总结

【刷題篇】鹅廠文化衫問題

迁移/home分区

如何安装mysql
随机推荐
怎样在电脑上设置路由器的WiFi密码
Win11提示无法安全下载软件怎么办?Win11无法安全下载软件
Using graylog alarm function to realize the regular work reminder of nail group robots
Global Data Center released DC brain system, enabling intelligent operation and management through science and technology
Dare not buy thinking
Seaborn绘制11个柱状图
Sentinel-流量防卫兵
面对新的挑战,成为更好的自己--进击的技术er
给自己打打气
《MongoDB入门教程》第04篇 MongoDB客户端
Domestic API management artifact used by the company
Exception com alibaba. fastjson. JSONException: not match : - =
【刷題篇】鹅廠文化衫問題
单商户 V4.4,初心未变,实力依旧!
Today's sleep quality record 79 points
Quelques réflexions cognitives
How can programmers improve their situation?
公司自用的国产API管理神器
ES6 drill down - Async functions and symbol types
迁移/home分区