Skip to content

Commit 199a76c

Browse files
authored
Create Count Subarrays of Length Three With a Condition.java
1 parent 8738cee commit 199a76c

File tree

1 file changed

+11
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)