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, 18456 Search Bots | 92 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 1355 Views, 18456 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, 18456 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
- First and Last Indices of an Element in a Sorted Array
- Daily Interview Problem: Trapping Rainwater
- Algorithm Interview: Level Order Traversal of Binary Tree
- Daily Interview Problem: Circle of Chained Words
- Multitasking
- Daily Interview Problem: Largest Product of 3 Elements I
- Most Frequent Subtree Sum
- [Daily Problem] Validate Balanced Parentheses
- CPU Utilization
- Daily Interview Question: Find Cycles in a Graph
©2006~2024 SteakOverCooked - 0.01237 Seconds(s) - 4358.204 KB/s - 86 Online Memory: 515.45 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 !