1. Two Sum
Easy
- Programmeertaal:
- Python
- Rating:
- 2.0/10
- Runtime ms:
- 999.99
- Runtime Percentage:
- 5.00%
- Memory MB:
- 19.56
- Memory Percentage:
- 99.42%
Functions:
- len()
Data Structures:
- list
Control Structures:
- while loop
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
slow, fast = 0, 1
while True:
if fast == len(nums):
slow += 1
fast = slow + 1
if nums[slow] + nums[fast] == target:
return [slow, fast]
else:
fast += 1