leetcode

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

commit07b55b095620042e1cdb72094af3ffd2587f35f2
parent30bdd949e3c8839eafabfb96572fdac0c8c872bd
authorDimitrije Dobrota <mail@dimitrijedobrota.com>
dateThu, 22 Aug 2024 18:06:55 +0200

Daily problem, and the same one

Diffstat:
AProblems/0476.cpp|++++
AProblems/1009.cpp|+++++++
MREADME.md|++

3 files changed, 13 insertions(+), 0 deletions(-)


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

@@ -0,0 +1,4 @@

class Solution {
public:
int findComplement(unsigned num) const { return num ^ (0xFFFFFFFF >> std::countl_zero(num)); }
};

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

@@ -0,0 +1,7 @@

class Solution {
public:
int bitwiseComplement(unsigned num) const {
if (num == 0) return 1;
return num ^ (0xFFFFFFFF >> std::countl_zero(num));
}
};

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

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

| 0462 | Medium | [Minimum Moves to Equal Array Elements II](Problems/0462.cpp) |
| 0463 | Easy | [Island Perimeter](Problems/0463.cpp) |
| 0472 | Hard | [Concatenated Words](Problems/0472.cpp) |
| 0476 | Easy | [Number Complement](Problems/0476.cpp) |
| 0477 | Medium | [Total Hamming Distance](Problems/0477.cpp) |
| 0481 | Medium | [Magical String](Problems/0481.cpp) |
| 0485 | Easy | [Max Consecutive Ones](Problems/0485.cpp) |

@@ -628,6 +629,7 @@ for solving problems.

| 1006 | Medium | [Clumsy Factorial](Problems/1006.cpp) |
| 1007 | Medium | [Minimum Domino Rotations For Equal Row](Problems/1007.cpp) |
| 1008 | Medium | [Construct Binary Search Tree from Preorder Traversal](Problems/1008.cpp) |
| 1009 | Easy | [Complement of Base 10 Integer](Problems/1009.cpp) |
| 1010 | Medium | [Pairs of Songs With Total Durations Divisible by 60](Problems/1010.cpp) |
| 1011 | Medium | [Capacity To Ship Packages Within D Days](Problems/1011.cpp) |
| 1014 | Medium | [Best Sightseeing Pair](Problems/1014.cpp) |