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

Sign up
Appearance settings

Commit 4ef024e

Browse files
Add C++ solution of problem #3392
1 parent 8823cf4 commit 4ef024e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

‎3392/solution.cpp‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public:
3+
int countSubarrays(vector<int>& A) {
4+
int ans = 0;
5+
for(int i = 0; i < A.size() - 2; i++) {
6+
int a = A[i];
7+
int b = A[i + 1];
8+
int c = A[i + 2];
9+
if(2 * (a + c) == b)
10+
ans++;
11+
}
12+
return ans;
13+
}
14+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /