Skip to content

Commit d662596

Browse files
authored
Refine comments and time complexity notation
Update comments and time complexity in the code.
1 parent 8143aa1 commit d662596

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)