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 | 1355 Views, 18432 Search Bots | 92 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 1355 Views, 18432 Search Bots | 92 Words
| 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:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 1355 Views, 18432 Search Bots | 92 Words 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]]
Related Articles
- Spreadsheet Columns
- Daily Interview Puzzle: Ways to Traverse a Grid
- Making a Height Balanced Binary Search Tree
- Algorithm Interview: Permutations of numbers
- [Daily Problem] Angles of a Clock
- Daily Interview Problem: Minimum Removals for Valid Parenthesis
- Daily Interview Problem: Largest BST in a Binary Tree
- Daily Interview Problem: Queue Using Two Stacks
- Algorithm Interview: Determine If Linked List is Palindrome
- Longest Substring Without Repeating Characters
©2006~2024 SteakOverCooked - 0.00987 Seconds(s) - 5494.264 KB/s - 34 Online Memory: 515.92 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !