about | help | code help+videos | done | prefs |
Given the array {7, 5, 1, 2, 3, 1}, it has many "subarrays" such as {5, 1, 2}, and {2, 3}, and {7}, and even {7, 5, 1, 2, 3, 1} (an array is a subarray of itself). If you look carefully, you can find a subarray whose elements add up to 1, a subarray whose elements add up to 2, a subarray whose elements add up to 3. In fact, with the array {7, 5, 1, 2, 3, 1}, you can find subarrays whose elements total 1, 2, 3, 4, 5, 6, 7, and 8, but you cannot find a subarray whose elements total 9. Given an array, find the smallest positive integer that cannot be obtained by adding together the elements in one of its subarrays. cantMakeIt([7, 5, 1, 2, 3, 1]) → 9 cantMakeIt([4, 3]) → 1 cantMakeIt([1, 2, 3, 4]) → 8 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 300
Copyright Nick Parlante 2017 - privacy