leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE |

commit89a29be83d226560613b2dbb7fa5a95958e4bd1a
parent199fe948b9a76833844ec9d6ebd947c3509a1a18
authorDimitrije Dobrota <mail@dimitrijedobrota.com>
dateThu, 26 Jan 2023 13:48:07 +0100

Data Structure I: Day 5

Diffstat:
MProblems/0036.cpp|++----------------------
AProblems/0074.cpp|++
MREADME.md|+

3 files changed, 5 insertions(+), 22 deletions(-)


diff --git a/Problems/0036.cpp b/Problems/0036.cpp

@@ -1,22 +1,2 @@

class Solution {
public:
bool isValidSudoku(vector<vector<char>> &board) {
function check = [&board](unordered_set<char> &us, int i, int j) {
if (board[i][j] != '.' && us.count(board[i][j])) return false;
us.insert(board[i][j]);
return true;
};
unordered_set<char> us1, us2, us3;
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++)
if (!check(us1, i, j) || !check(us2, j, i) ||
!check(us3, 3 * (i / 3) + (j / 3), 3 * (i % 3) + (j % 3)))
return false;
us1.clear();
us2.clear();
us3.clear();
}
return true;
}
};
Formating: Problems/0036.cpp
Formating: Problems/0074.cpp

diff --git a/Problems/0074.cpp b/Problems/0074.cpp

@@ -0,0 +1,2 @@

Formating: Problems/0036.cpp
Formating: Problems/0074.cpp

diff --git a/README.md b/README.md

@@ -57,6 +57,7 @@ for solving problems.

| 0066 | Easy | [Plus One](Problems/0066.cpp) |
| 0067 | Easy | [Add Binary](Problems/0067.cpp) |
| 0070 | Easy | [Climbing Stairs](Problems/0070.cpp) |
| 0074 | Medium | [Search a 2D Matrix](Problems/0074.cpp) |
| 0083 | Easy | [Remove Duplicates from Sorted List](Problems/0083.cpp) |
| 0084 | Hard | [Largest Rectangle in Histogram](Problems/0084.cpp) |
| 0088 | Easy | [Merge Sorted Array](Problems/0088.cpp) |