3152. 特殊数组 II
题目链接:3152. 特殊数组 II
代码如下:
class Solution
{
public:
vector<bool> isArraySpecial(vector<int>& nums, vector<vector<int>>& queries)
{
vector<int> d(nums.size());
//std::iota(numbers.begin(), numbers.end(), startValue);
iota(d.begin(),d.end(),0);
for(int i=1;i<nums.size();i++)
{
if(nums[i-1]%2!=nums[i]%2)
{
d[i]=d[i-1];
}
}
vector<bool> res;
for(const auto& q:queries)
{
res.push_back(d[q[1]]<=q[0]);
}
return res;
}
};
标签:nums,II,3152,vector,numbers,数组
From: https://blog.csdn.net/weixin_45256307/article/details/141183810