leetcode

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

commit 35f23abc81676fb7e3d07462f932211ebf74bd85
parent 60bbca57a435dfc044ce061db6ce810789830f6e
author Dimitrije Dobrota <mail@dimitrijedobrota.com>
date Fri, 23 Feb 2024 09:44:30 +0000

1 Random Problem

Diffstat:
A Problems/2424.cpp | ++++++++++++++++++++
M README.md | +

2 files changed, 21 insertions(+), 0 deletions(-)


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

@@ -0,0 +1,20 @@
class LUPrefix {
public:
LUPrefix(int n) : n(n) { memset(seen, 0x00, sizeof(seen)); }
void upload(int video) { seen[video] = true; }
int longest() const {
while (seen[next])
next++;
return next - 1;
}
private:
const int n;
mutable int next = 1;
static int seen[100001];
};
int LUPrefix::seen[100001];

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

@@ -1054,6 +1054,7 @@ for solving problems. | 2415 | Medium | [Reverse Odd Levels of Binary Tree](Problems/2415.cpp) | | 2421 | Medium | [Number of Good Paths](Problems/2421.cpp) | | 2423 | Easy | [Remove Letter To Equalize Frequency](Problems/2423.cpp) |
| 2424 | Medium | [Longest Uploaded Prefix](Problems/2424.cpp) |
| 2425 | Medium | [Bitwise XOR of All Pairings](Problems/2425.cpp) | | 2428 | Medium | [Maximum Sum of an Hourglass](Problems/2428.cpp) | | 2433 | Medium | [Find The Original Array of Prefix Xor](Problems/2433.cpp) |