mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-13 14:57:08 +00:00
Removing old questions
Removed questions uploaded using an old version of LeetHub Questions 2,3,4,19,36,141,206
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
class Solution(object):
|
||||
def isValidSudoku(self, board):
|
||||
"""
|
||||
:type board: List[List[str]]
|
||||
:rtype: bool
|
||||
"""
|
||||
# Check horizontals
|
||||
for i in range(len(board)):
|
||||
inRow = [False] * 10
|
||||
|
||||
for j in range(len(board[i])):
|
||||
if board[i][j] == ".":
|
||||
continue
|
||||
else:
|
||||
if inRow[int(board[i][j])]:
|
||||
return False
|
||||
else:
|
||||
inRow[int(board[i][j])] = True
|
||||
|
||||
|
||||
# Check verticals
|
||||
for j in range(len(board[0])):
|
||||
inColumn = [False] * 10
|
||||
|
||||
for i in range(len(board)):
|
||||
if board[i][j] == ".":
|
||||
continue
|
||||
else:
|
||||
if inColumn[int(board[i][j])]:
|
||||
return False
|
||||
else:
|
||||
inColumn[int(board[i][j])] = True
|
||||
|
||||
# Check boxes
|
||||
for boxI in range(3):
|
||||
for boxJ in range(3):
|
||||
inBox = [False] * 10
|
||||
for i in range(3):
|
||||
for j in range(3):
|
||||
if board[(boxI * 3) + i][(boxJ * 3) + j] == ".":
|
||||
continue
|
||||
else:
|
||||
if inBox[int(board[(boxI * 3) + i][(boxJ * 3) + j])]:
|
||||
return False
|
||||
else:
|
||||
inBox[int(board[(boxI * 3) + i][(boxJ * 3) + j])] = True
|
||||
|
||||
return True
|
||||
@@ -1,56 +0,0 @@
|
||||
<h2><a href="https://leetcode.com/problems/valid-sudoku/">36. Valid Sudoku</a></h2><h3>Medium</h3><hr><div><p>Determine if a <code>9 x 9</code> Sudoku board is valid. Only the filled cells need to be validated <strong>according to the following rules</strong>:</p>
|
||||
|
||||
<ol>
|
||||
<li>Each row must contain the digits <code>1-9</code> without repetition.</li>
|
||||
<li>Each column must contain the digits <code>1-9</code> without repetition.</li>
|
||||
<li>Each of the nine <code>3 x 3</code> sub-boxes of the grid must contain the digits <code>1-9</code> without repetition.</li>
|
||||
</ol>
|
||||
|
||||
<p><strong>Note:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li>A Sudoku board (partially filled) could be valid but is not necessarily solvable.</li>
|
||||
<li>Only the filled cells need to be validated according to the mentioned rules.</li>
|
||||
</ul>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Sudoku-by-L2G-20050714.svg/250px-Sudoku-by-L2G-20050714.svg.png" style="height:250px; width:250px">
|
||||
<pre><strong>Input:</strong> board =
|
||||
[["5","3",".",".","7",".",".",".","."]
|
||||
,["6",".",".","1","9","5",".",".","."]
|
||||
,[".","9","8",".",".",".",".","6","."]
|
||||
,["8",".",".",".","6",".",".",".","3"]
|
||||
,["4",".",".","8",".","3",".",".","1"]
|
||||
,["7",".",".",".","2",".",".",".","6"]
|
||||
,[".","6",".",".",".",".","2","8","."]
|
||||
,[".",".",".","4","1","9",".",".","5"]
|
||||
,[".",".",".",".","8",".",".","7","9"]]
|
||||
<strong>Output:</strong> true
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
|
||||
<pre><strong>Input:</strong> board =
|
||||
[["8","3",".",".","7",".",".",".","."]
|
||||
,["6",".",".","1","9","5",".",".","."]
|
||||
,[".","9","8",".",".",".",".","6","."]
|
||||
,["8",".",".",".","6",".",".",".","3"]
|
||||
,["4",".",".","8",".","3",".",".","1"]
|
||||
,["7",".",".",".","2",".",".",".","6"]
|
||||
,[".","6",".",".",".",".","2","8","."]
|
||||
,[".",".",".","4","1","9",".",".","5"]
|
||||
,[".",".",".",".","8",".",".","7","9"]]
|
||||
<strong>Output:</strong> false
|
||||
<strong>Explanation:</strong> Same as Example 1, except with the <strong>5</strong> in the top left corner being modified to <strong>8</strong>. Since there are two 8's in the top left 3x3 sub-box, it is invalid.
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>board.length == 9</code></li>
|
||||
<li><code>board[i].length == 9</code></li>
|
||||
<li><code>board[i][j]</code> is a digit <code>1-9</code> or <code>'.'</code>.</li>
|
||||
</ul>
|
||||
</div>
|
||||
Reference in New Issue
Block a user