Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ad27c7e

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

File tree

Expand file treeCollapse file tree

1 file changed

+11
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-0
lines changed
+11Lines changed: 11 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.