Simple solution, get TLE though

  • 0
    class Solution(object):
        def threeSum(self, nums):
            :type nums: List[int]
            :rtype: List[List[int]]
            import itertools
            ls = []
            for subset in itertools.combinations(nums, 3):
                if sum(list(subset))==0:
                    # first I have sorted the list because of grouping
                    # Ex: [-1, 0, 1] and [0, 1, -1] are build with the same element
                    # so here is avoiding this.
                    if list(subset) not in ls:
            return ls

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.