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 | 1121 Views, 16331 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 | 1121 Views, 16331 Search Bots | 92 Words Subscribe to Feed Burner

Related Articles

  1. [Daily Problem] Remove k-th Last Element From Linked List
  2. New Vulnerabilities (CVE-2016-4581) have been detected in CentOS/RHEL/CloudLinux 7
  3. Longest Substring Without Repeating Characters
  4. Daily Interview Problem: Get all Values at a Certain Height in a Binary Tree
  5. Find the non-duplicate number
  6. Daily Interview Problem: Largest BST in a Binary Tree
  7. Daily Interview Problem: Reconstrunct Binary Tree from Preorder and Inorder Traversals
  8. Batch Programming in XP
  9. How to Play WAV music under DOS?
  10. [Daily Problem] Longest Increasing Subsequence

Comments (0)

    Be the first one to comment this page !


Page Edited: May 11 2024 14:36:49 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="index, follow">