leetcode

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

1023.cpp (721B)


      1 class Solution {
      2   public:
      3     vector<bool> camelMatch(const vector<string> &queries, const string &pattern) {
      4         vector<bool> res(queries.size(), false);
      5         for (int k = 0; k < queries.size(); k++) {
      6             const string &query = queries[k];
      7             int i = 0, j = 0;
      8             while (i < query.size()) {
      9                 if (!isupper(query[i])) {
     10                     if (query[i] == pattern[j]) j++;
     11                     i++;
     12                 } else {
     13                     if (j == pattern.size() || query[i] != pattern[j]) goto next;
     14                     i++, j++;
     15                 }
     16             }
     17             if (j == pattern.size()) res[k] = true;
     18         next:;
     19         }
     20         return res;
     21     }
     22 };