File: root - text - article - 2020 - 01 - smallest-number-that-is-not-a-sum-of-a-subset-of-list.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 453 Views, 52835 Search Bots | 66 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 453 Views, 52835 Search Bots | 66 Words
| Browse | Archive
Hi, here's your problem today. This problem was recently asked by AirBNB:
Given a sorted list of positive numbers, find the smallest positive number that cannot be a sum of any subset in the list.
Example:
Input: [1, 2, 3, 8, 9, 10]
Output: 7
Numbers 1 to 6 can all be summed by a subset of the list of numbers, but 7 cannot.
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 453 Views, 52835 Search Bots | 66 Words Given a sorted list of positive numbers, find the smallest positive number that cannot be a sum of any subset in the list.
Example:
Input: [1, 2, 3, 8, 9, 10]
Output: 7
Numbers 1 to 6 can all be summed by a subset of the list of numbers, but 7 cannot.
def findSmallest(nums):
# Fill this in.
print findSmallest([1, 2, 3, 8, 9, 10])
# 7
Related Articles
- Daily Interview Puzzle: Minimum Size Subarray Sum
- Algorithm Interview: Lowest Common Ancestor of 2 Nodes in Binary Tree
- Daily Interview Question: Edit Distance
- Daily Interview Problem: Merge List Of Number Into Ranges
- Daily Interview Problem: Circle of Chained Words
- Sorting a list with 3 unique numbers
- Find Pythagorean Triplets
- Algorithm Interview Question: H-Index
- Daily Interview Problem: Full Binary Tree
- Find Missing Numbers in an Array
©2006~2024 SteakOverCooked - 0.0102 Seconds(s) - 1933.301 KB/s - 39 Online Memory: 494.7 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="index, 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 !