Skip to content

Commit a4b59b8

Browse files
authored
Create maximum-number-of-operations-with-the-same-score-i.py
1 parent fd58b48 commit a4b59b8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
# array
5+
class Solution(object):
6+
def maxOperations(self, nums):
7+
"""
8+
:type nums: List[int]
9+
:rtype: int
10+
"""
11+
result = 1
12+
target = nums[0]+nums[1]
13+
for i in xrange(2, len(nums)-1, 2):
14+
if nums[i]+nums[i+1] != target:
15+
break
16+
result += 1
17+
return result

0 commit comments

Comments
 (0)