deadpyxel / fct-hacktoberfest-challenges

Desafios para o Hacktoberfest 2019 na FCT UNESP
1 stars 8 forks source link

3 Sum #25

Open deadpyxel opened 5 years ago

deadpyxel commented 5 years ago

asked by Twitter:

Given an array, nums, of n integers, find all unique triplets (three numbers, a, b, & c) in nums such that a + b + c = 0. Note that there may not be any triplets that sum to zero in nums, and that the triplets must not be duplicates.

Example:

Input: nums = [0, -1, 2, -3, 1]
Output: [0, -1, 1], [2, -3, 1]

Here's a starting point:

class Solution(object):
  def threeSum(self, nums):
    # Fill this in.

# Test Program
nums = [1, -2, 1, 0, 5]
print(Solution().threeSum(nums))
# [[-2, 1, 1]]
Ellyzeul commented 5 years ago

Farei este problema em C

Ellyzeul commented 5 years ago

Código em C já implementado.