To the Top
File:  root - text - article - 2019 - 12 - 3-sum.txt.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 1035 Views, 14134 Search Bots | 92 Words

Subscribe to Feed Burner | Browse | Archive
Hi, here's your problem today. This problem was recently 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]]
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 1035 Views, 14134 Search Bots | 92 Words Subscribe to Feed Burner

Related Articles

  1. Daily Interview Problem: Decode String
  2. Batch Programming in XP
  3. Fibonacci coding
  4. Daily Interview Question: Longest Sequence with Two Unique Numbers
  5. Daily Interview Problem: First Missing Positive Integer
  6. Staying on a Chess Board
  7. Compare Version Numbers
  8. Algorithm Interview: Shifted String
  9. Algorithm Interview: Subarray With Target Sum
  10. Daily Interview Problem: Product of Array Except Self

Comments (0)

Your Email (Domain Part Not Exposed):

Your Comments:

Privately By Mail Colors More Smileys S x y @

Verification (Click Image 2 Refresh):

    Be the first one to comment this page !


Page Edited: October 30 2020 14:21:09 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />