leetcode

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

2900.cpp (430B)


      1 class Solution {
      2   public:
      3     vector<string> getWordsInLongestSubsequence(const int n, const vector<string> &words,
      4                                                 const vector<int> &groups) const {
      5         vector<string> res;
      6         int crnt = groups[0];
      7         res.push_back(words[0]);
      8         for (int i = 1; i < n; i++)
      9             if (groups[i] != crnt) res.push_back(words[i]), crnt = !crnt;
     10         return res;
     11     }
     12 };