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 | 448 Views, 52423 Search Bots | 66 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 448 Views, 52423 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 | 448 Views, 52423 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 Problem: Decode String
- Compare Version Numbers
- Top K Frequent words
- Find Missing Numbers in an Array
- Daily Interview Problem: Find the Number of Islands
- [Daily Problem] Longest Increasing Subsequence
- Algorithm Interview: Subarray With Target Sum
- Daily Interview Problem: Word Ordering in a Different Alphabetical Order
- Daily Interview Problem: Merge Overlapping Intervals
- Kaprekar
©2006~2024 SteakOverCooked - 0.00857 Seconds(s) - 2247.779 KB/s - 29 Online Memory: 492.08 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 !