Skip to content

Commit 0ee512b

Browse files
authored
Fix time complexity notation in Compute Alternating Sum
Updated time complexity notation to O(n + n).
1 parent 5b75f46 commit 0ee512b

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)