分享一道阿里巴巴(蚂蚁金服)Java笔试题

编写一个函数验证一个给定的9x9 整数矩阵是否符合数独的特性:
a) 每个单元格数字为 1-9
b) 每行的9个数不重复
c) 每列的9个数不重复
d) 如图中分割的9个小3x3矩阵,每个小矩阵里9个数不重复

+-----+-----+-----+-----+-----+-----+-----+-----+-----+
|  x  |  x  |  x  |     |     |     |  x  |  x  |  x  |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
|  x  |  x  |  x  |     |     |     |  x  |  x  |  x  |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
|  x  |  x  |  x  |     |     |     |  x  |  x  |  x  |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
|     |     |     |  x  |  x  |  x  |     |     |     |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
|     |     |     |  x  |  x  |  x  |     |     |     |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
|     |     |     |  x  |  x  |  x  |     |     |     |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
|  x  |  x  |  x  |     |     |     |  x  |  x  |  x  |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
|  x  |  x  |  x  |     |     |     |  x  |  x  |  x  |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
|  x  |  x  |  x  |     |     |     |  x  |  x  |  x  |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+

 

posted @ 2018-03-26 16:49  晨羲  阅读(665)  评论(0编辑  收藏  举报