Skip to content

Commit

Permalink
Time: 73 ms (86.85%), Space: 25.9 MB (59.83%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
Dipendra-Raghav committed Nov 28, 2022
1 parent f82b983 commit d06d31d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions 1630-arithmetic-subarrays/1630-arithmetic-subarrays.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution {
public:

vector<bool> checkArithmeticSubarrays(vector<int>& nums, vector<int>& l, vector<int>& r) {
vector<bool> res;
for (auto i = 0, j = 0; i < l.size(); ++i) {
vector<int> n(begin(nums) + l[i], begin(nums) + r[i] + 1);
sort(begin(n), end(n));
for (j = 2; j < n.size(); ++j)
if (n[j] - n[j - 1] != n[1] - n[0])
break;
res.push_back(j == n.size());
}
return res;
}
};

0 comments on commit d06d31d

Please sign in to comment.