Skip to content

Commit 813063e

Browse files
authored
Create 3392. Count Subarrays of Length Three With a Condition.py
1 parent 0541351 commit 813063e

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#
2+
3+
'''
4+
1. 아이디어 :
5+
-
6+
7+
2. 시간복잡도 :
8+
O(n-2)
9+
10+
3. 자료구조/알고리즘 :
11+
-
12+
13+
'''
14+
class Solution:
15+
def countSubarrays(self, nums: List[int]) -> int:
16+
n = len(nums)
17+
ans = 0
18+
for i in range(n-2):
19+
if (nums[i] + nums[i+2]) * 2== nums[i+1]:
20+
ans+=1
21+
return ans

0 commit comments

Comments
 (0)