Skip to content

Commit a685898

Browse files
committed
3392. total subarrays with condition
1 parent f27d998 commit a685898

File tree

1 file changed

+16
-0
lines changed
  • easy/3392-total-subarrays-with-condition

1 file changed

+16
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <vector>
2+
using namespace std;
3+
4+
class Solution {
5+
public:
6+
int countSubarrays(vector<int>& nums) {
7+
int left = 0, right = 2;
8+
int total = 0;
9+
10+
for(;right<nums.size();right+=1,left+=1)
11+
if(2*(nums[left] + nums[right]) == nums[left+1])
12+
total += 1;
13+
14+
return total;
15+
}
16+
};

0 commit comments

Comments
 (0)