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 | 1354 Views, 18413 Search Bots | 92 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 1354 Views, 18413 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 | 1354 Views, 18413 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
- Delphi Dynamic Array
- Daily Interview Problem: Jump to the End
- Daily Interview Problem: Contiguous Subarray with Maximum Sum
- [Daily Problem] Validate Balanced Parentheses
- Kaprekar
- Daily Interview Problem: Distribute Bonuses
- Fibonacci coding
- [Daily Problem] Longest Increasing Subsequence
- [Daily Problem] Remove Consecutive Nodes that Sum to 0
- Algorithm Interview: Permutations of numbers
©2006~2024 SteakOverCooked - 0.01164 Seconds(s) - 4617.606 KB/s - 34 Online Memory: 528.51 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 !