leetcode

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

3152.cpp (456B)


      1 class Solution {
      2   public:
      3     vector<bool> isArraySpecial(const vector<int> &nums, const vector<vector<int>> &queries) const {
      4         static int vec[100001];
      5 
      6         for (int i = 1; i < size(nums); i++) {
      7             vec[i] = vec[i - 1] + (nums[i - 1] % 2 == nums[i] % 2);
      8         }
      9 
     10         vector<bool> res;
     11         for (const auto &query : queries) {
     12             res.push_back(vec[query[0]] == vec[query[1]]);
     13         }
     14 
     15         return res;
     16     }
     17 };