Skip to content

Commit ad27c7e

Browse files
authored
Create 3392. Count Subarrays of Length Three With a Condition (#779)
2 parents c8c5f18 + baef37f commit ad27c7e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public:
3+
int countSubarrays(vector<int>& nums) {
4+
int n = nums.size();
5+
int count = 0;
6+
for(int i=0;i<n-2;i++){
7+
if(nums[i] + (float)nums[i+2] == (nums[i+1]/(float)2)) count++;
8+
}
9+
return count;
10+
}
11+
};

0 commit comments

Comments
 (0)