leetcode

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

commit dfedfb533e88455a89a0d208613a4738295d7b9d
parent ab9cd2da44c7062aa21fda6d76cc031923032c8b
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Thu, 20 Apr 2023 15:17:34 +0200

Random Problem

Diffstat:
AProblems/0080.cpp | 15+++++++++++++++
MREADME.md | 1+
2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/Problems/0080.cpp b/Problems/0080.cpp @@ -0,0 +1,15 @@ +class Solution { +public: + int removeDuplicates(vector<int> &nums) { + int k = 1; + for (int i = 1; i < nums.size(); i++) { + nums[k++] = nums[i]; + if (nums[i] == nums[i - 1]) { + while (++i < nums.size() && nums[i] == nums[k - 2]) + ; + i--; + } + } + return k; + } +}; diff --git a/README.md b/README.md @@ -97,6 +97,7 @@ for solving problems. | 0077 | Medium | [Combinations](Problems/0077.cpp) | | 0078 | Medium | [Subsets](Problems/0078.cpp) | | 0079 | Medium | [Word Search](Problems/0079.cpp) | +| 0080 | Medium | [Remove Duplicates from Sorted Array II](Problems/0080.cpp) | | 0082 | Medium | [Remove Duplicates from Sorted List II](Problems/0082.cpp) | | 0083 | Easy | [Remove Duplicates from Sorted List](Problems/0083.cpp) | | 0084 | Hard | [Largest Rectangle in Histogram](Problems/0084.cpp) |