leetcode

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

commit d8f69f38f877dffd90f5a68c8ec20743a514e966
parent c1f56d362048716e92433a99382f513ff8bd68b4
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Fri,  3 Feb 2023 13:58:03 +0100

Algorithm I: Day 14 FINISH

Diffstat:
AProblems/0136.cpp | 8++++++++
AProblems/0190.cpp | 12++++++++++++
MREADME.md | 2++
3 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/Problems/0136.cpp b/Problems/0136.cpp @@ -0,0 +1,8 @@ +class Solution { +public: + int singleNumber(vector<int> &nums) { + int res = 0; + for (const int n : nums) res ^= n; + return res; + } +}; diff --git a/Problems/0190.cpp b/Problems/0190.cpp @@ -0,0 +1,12 @@ +class Solution { +public: + uint32_t reverseBits(uint32_t n) { + int count = 32, res = 0; + while (count--) { + res <<= 1; + res += n & 1; + n >>= 1; + } + return res; + } +}; diff --git a/README.md b/README.md @@ -98,6 +98,7 @@ for solving problems. | 0133 | Medium | [Clone Graph](Problems/0133.cpp) | | 0134 | Medium | [Gas Station](Problems/0134.cpp) | | 0135 | Hard | [Candy](Problems/0135.cpp) | +| 0136 | Easy | [Single Number](Problems/0136.cpp) | | 0138 | Medium | [Copy List with Random Pointer](Problems/0138.cpp) | | 0139 | Medium | [Word Break](Problems/0139.cpp) | | 0141 | Easy | [Linked List Cycle](Problems/0141.cpp) | @@ -115,6 +116,7 @@ for solving problems. | 0167 | Medium | [Two Sum II - Input Array Is Sorted](Problems/0167.cpp) | | 0173 | Medium | [Binary Search Tree Iterator](Problems/0173.cpp) | | 0189 | Medium | [Rotate Array](Problems/0189.cpp) | +| 0190 | Easy | [Reverse Bits](Problems/0190.cpp) | | 0191 | Easy | [Number of 1 Bits](Problems/0191.cpp) | | 0192 | Medium | [Word Frequency](Problems/0192.sh) | | 0193 | Easy | [Valid Phone Numbers](Problems/0193.sh) |