leetcode

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

commit 9c2ca75178c23ea2e2fbc498fdb8c1e955f01988
parent 7f2cf9b027c71b6c1c586a7f2e12741a76cd9889
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Thu, 30 Nov 2023 11:56:21 +0000

Daily Problem

Diffstat:
AProblems/1611.cpp | 11+++++++++++
MREADME.md | 1+
2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/Problems/1611.cpp b/Problems/1611.cpp @@ -0,0 +1,11 @@ +class Solution { + public: + int minimumOneBitOperations(int n) const { + bitset<32> res, num(n); + res[31] = num[31]; + for (int i = 30; i >= 0; i--) { + res[i] = res[i + 1] ^ num[i]; + } + return res.to_ulong(); + } +}; diff --git a/README.md b/README.md @@ -689,6 +689,7 @@ for solving problems. | 1603 | Easy | [Design Parking System](Problems/1603.cpp) | | 1605 | Medium | [Find Valid Matrix Given Row and Column Sums](Problems/1605.cpp) | | 1609 | Medium | [Even Odd Tree](Problems/1609.cpp) | +| 1611 | Hard | [Minimum One Bit Operations to Make Integers Zero](Problems/1611.cpp) | | 1615 | Medium | [Maximal Network Rank](Problems/1615.cpp) | | 1625 | Medium | [Lexicographically Smallest String After Applying Operations](Problems/1625.cpp) | | 1626 | Medium | [Best Team With No Conflicts](Problems/1626.cpp) |