leetcode

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

commitdb17af74f6e01d983ba278bd273e8f8c8a7a92e6
parent90db16afd264cf02d841d815f66aceaf85062b22
authorDimitrije Dobrota <mail@dimitrijedobrota.com>
dateSat, 21 Oct 2023 18:15:57 +0000

2 Random Problems

Diffstat:
AProblems/1017.cpp|++++++++++++
AProblems/1760.cpp|+++++++++++++++++
MREADME.md|++

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


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

@@ -0,0 +1,12 @@

class Solution {
public:
string baseNeg2(int n) {
if (n == 0) return "0";
string res;
do {
res += to_string(n & 1);
} while ((n = -(n >> 1)));
reverse(begin(res), end(res));
return res;
}
};

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

@@ -0,0 +1,17 @@

class Solution {
public:
int minimumSize(const vector<int> &nums, const int maxOperations) const {
int low = 1, high = 1E9;
while (low <= high) {
const int mid = low + (high - low) / 2;
int op = 0;
for (const int n : nums)
op += (n - 1) / mid;
if (op > maxOperations)
low = mid + 1;
else
high = mid - 1;
}
return low;
}
};

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

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

| 1008 | Medium | [Construct Binary Search Tree from Preorder Traversal](Problems/1008.cpp) |
| 1011 | Medium | [Capacity To Ship Packages Within D Days](Problems/1011.cpp) |
| 1014 | Medium | [Best Sightseeing Pair](Problems/1014.cpp) |
| 1017 | Medium | [Convert to Base -2](Problems/1017.cpp) |
| 1019 | Medium | [Next Greater Node In Linked List](Problems/1019.cpp) |
| 1020 | Medium | [Number of Enclaves](Problems/1020.cpp) |
| 1022 | Easy | [Sum of Root To Leaf Binary Numbers](Problems/1022.cpp) |

@@ -703,6 +704,7 @@ for solving problems.

| 1743 | Medium | [Restore the Array From Adjacent Pairs](Problems/1743.cpp) |
| 1751 | Hard | [Maximum Number of Events That Can Be Attended II](Problems/1751.cpp) |
| 1753 | Medium | [Maximum Score From Removing Stones](Problems/1753.cpp) |
| 1760 | Medium | [Minimum Limit of Balls in a Bag](Problems/1760.cpp) |
| 1765 | Medium | [Map of Highest Peak](Problems/1765.cpp) |
| 1768 | Easy | [Merge Strings Alternately](Problems/1768.cpp) |
| 1769 | Medium | [Minimum Number of Operations to Move All Balls to Each Box](Problems/1769.cpp) |