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 | 483 Views, 55498 Search Bots | 66 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 483 Views, 55498 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 | 483 Views, 55498 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
- CVE-2015-8874 - cPanel EasyApache Vulnerabilities
- Daily Interview Problem: Room scheduling
- Algorithm Interview: Make the Largest Number
- Linode Support Ticket 10029540 - Other - Important Notice Regarding Ubuntu 17.10 Image
- Daily Interview Problem: Count Number of Unival Subtrees
- Spreadsheet Columns
- Algorithm Interview: No Adjacent Repeating Characters
- Daily Interview Problem: Reverse Integer
- Invert a Binary Tree
- Algorithm Interview: String Compression
©2006~2024 SteakOverCooked - 0.00721 Seconds(s) - 2774.802 KB/s - 11 Online Memory: 495.2 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 !