We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents c8c5f18 + baef37f commit ad27c7eCopy full SHA for ad27c7e
3392. Count Subarrays of Length Three With a Condition
@@ -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