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 | 455 Views, 53119 Search Bots | 66 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 455 Views, 53119 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 | 455 Views, 53119 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: Ways to Traverse a Grid
- Algorithm Interview Question: Max and Min with Limited Comparisons
- Daily Interview Problem: 3 Sum
- [Daily Problem] Longest Palindromic Substring
- A trick for getting good at coding interviews FASTER
- How to Play WAV music under DOS?
- Daily Interview Problem: Merge List Of Number Into Ranges
- Daily Interview Problem: Largest BST in a Binary Tree
- Algorithm Interview: Shifted String
- Daily Interview Problem: Get all Values at a Certain Height in a Binary Tree
©2006~2024 SteakOverCooked - 0.00724 Seconds(s) - 2956.001 KB/s - 26 Online Memory: 495.38 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 !