leetcode

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

commit 95e2ee4efc673fe98b1ec3a561a56aa538ba87e7
parent a71264394dc0c6e18c40fc5498a9869c11d8a904
author Dimitrije Dobrota <mail@dimitrijedobrota.com>
date Sun, 25 Aug 2024 10:49:48 +0200

1 Random Problem

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

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


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

@@ -0,0 +1,16 @@
class Solution {
public:
ListNode *modifiedList(const vector<int> &nums, ListNode *head) const {
const unordered_set<int> us(begin(nums), end(nums));
ListNode dummy(-1, head);
for (auto *p = &dummy; p && p->next;) {
if (!us.count(p->next->val))
p = p->next;
else
p->next = p->next->next;
}
return dummy.next;
}
};

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

@@ -1327,6 +1327,7 @@ for solving problems. | 3195 | Medium | [Find the Minimum Area to Cover All Ones I](Problems/3195.cpp) | | 3211 | Medium | [Generate Binary Strings Without Adjacent Zeros](Problems/3211.cpp) | | 3212 | Medium | [Count Submatrices With Equal Frequency of X and Y](Problems/3212.cpp) |
| 3217 | Medium | [Delete Nodes From Linked List Present in Array](Problems/3217.cpp) |
| 3227 | Medium | [Vowels Game in a String](Problems/3227.cpp) | | 3228 | Medium | [Maximum Number of Operations to Move Ones to the End](Problems/3228.cpp) | | 3239 | Medium | [Minimum Number of Flips to Make Binary Grid Palindromic I](Problems/3239.cpp) |