leetcode

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

commit 2e2afaeb9584c00ccc92390e8efaa7b56efb5ccb
parent ab2acb5877703b508c92587a52a6e3d711d2e777
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Mon, 27 May 2024 16:25:58 +0200

Daily Problem

Diffstat:
AProblems/1608.cpp | 17+++++++++++++++++
MREADME.md | 1+
2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/Problems/1608.cpp b/Problems/1608.cpp @@ -0,0 +1,17 @@ +class Solution { + public: + int specialArray(const vector<int> &nums) const { + static int count[102]; + const int n = size(nums); + + memset(count, 0x00, sizeof(count)); + for (const int m : nums) + count[min(n, m)]++; + for (int i = size(nums); i >= 0; i--) { + count[i] += count[i + 1]; + if (count[i] == i) return i; + } + + return -1; + } +}; diff --git a/README.md b/README.md @@ -870,6 +870,7 @@ for solving problems. | 1601 | Hard | [Maximum Number of Achievable Transfer Requests](Problems/1601.cpp) | | 1603 | Easy | [Design Parking System](Problems/1603.cpp) | | 1605 | Medium | [Find Valid Matrix Given Row and Column Sums](Problems/1605.cpp) | +| 1608 | Easy | [Special Array With X Elements Greater Than or Equal X](Problems/1608.cpp) | | 1609 | Medium | [Even Odd Tree](Problems/1609.cpp) | | 1611 | Hard | [Minimum One Bit Operations to Make Integers Zero](Problems/1611.cpp) | | 1614 | Easy | [Maximum Nesting Depth of the Parentheses](Problems/1614.cpp) |