leetcode

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

commit e275d21fb0f091fd5b1fb683a1d92d05802b5881
parent 137b128c4eee4ec8ec4fd2af216f4924d0789c48
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Tue, 17 Oct 2023 19:50:23 +0000

Random Problem

Diffstat:
AProblems/2900.cpp | 12++++++++++++
MREADME.md | 1+
2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/Problems/2900.cpp b/Problems/2900.cpp @@ -0,0 +1,12 @@ +class Solution { + public: + vector<string> getWordsInLongestSubsequence(const int n, const vector<string> &words, + const vector<int> &groups) const { + vector<string> res; + int crnt = groups[0]; + res.push_back(words[0]); + for (int i = 1; i < n; i++) + if (groups[i] != crnt) res.push_back(words[i]), crnt = !crnt; + return res; + } +}; diff --git a/README.md b/README.md @@ -873,3 +873,4 @@ for solving problems. | 2785 | Medium | [Sort Vowels in a String](Problems/2785.cpp) | | 2799 | Medium | [Count Complete Subarrays in an Array](Problems/2799.cpp) | | 2807 | Medium | [Insert Greatest Common Divisors in Linked List](Problems/2807.cpp) | +| 2900 | Medium | [Longest Unequal Adjacent Groups Subsequence I](Problems/2900.cpp) |