array 1 

Run Settings
LanguagePython
Language Version
Run Command
from typing import List lis = ["a","b", "c", "d"] # for i in lis: # print(i) print(lis[2]) lis.append("e") lis.pop() lis.pop() lis.insert(0, 'x') # lis.insert(len(lis), 't') lis[3:3] = ['alien'] # lis.splice(2, 0, "alien") print(lis) print() def threeSum(nums: List[int]) -> List[List[int]]: total = len(nums) count = 0 for i, n in enumerate(nums): print(i, n) if (n + n[i + 1]) if total: return total else: return [] input = [-1,0,1,2,-1,-4] result = threeSum(input) print(result)
def threeSum(nums: List[int]) -> List[List[int]]: for i, n in enumerate(nums): print(i, n) if total: return total else: return [] input = [-1,0,1,2,-1,-4] result = threeSum(input) print(result)
class Solution: def threeSum(self, nums: List[int]) -> List[List[int]]: my_list = [] last = len(nums) - 1 for index, n in enumerate(nums): j = index + 1 if index > 0 and n == nums[index - 1]: continue while j < last: threeSum = n + nums[j] + nums[last] if threeSum > 0: last -= 1 if threeSum < 0: j += 1 else: my_list.append([n, nums[j], nums[last]]) j += 1 while nums[j] == nums[j -1] and j < last: j += 1 return my_list
Editor Settings
Theme
Key bindings
Full width
Lines