Skip to content

Commit 14056ee

Browse files
committed
Update two-sum-ii-input-array-is-sorted.py
1 parent 5f020bd commit 14056ee

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Python/two-sum-ii-input-array-is-sorted.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ def twoSum(self, nums, target):
1919
start, end = 0, len(nums) - 1
2020

2121
while start != end:
22-
if nums[start] + nums[end] > target:
22+
sum = nums[start] + nums[end]
23+
if sum > target:
2324
end -= 1
24-
elif nums[start] + nums[end] < target:
25+
elif sum < target:
2526
start += 1
2627
else:
2728
return [start + 1, end + 1]
2829

2930
if __name__ == "__main__":
30-
print Solution().twoSum([2, 7, 11, 15], 9)
31+
print Solution().twoSum([2, 7, 11, 15], 9)

0 commit comments

Comments
 (0)