about | help | code help+videos | done | prefs |
Write a RECURSIVE method that returns the number of different ways that 'target' can be reached by adding any number of numbers from the array 'nums'. For example, with the array {5,7,4,2,1} and the 'target' of 7, there are three different ways to add up numbers from that array to get 7 (5+2, 7, and 4+2+1). Different orders of the same numbers only count once, so 4+2+1 is not considered different from 2+1+4 or 1+2+4 etc. As a precondition, you may assume that 'nums' does not have any duplicate numbers. I strongly encourage you to write a helper method! Remember that your solution must be RECURSIVE. apr_9_2019_SLHL_recursiveSumCount([233, 239, 241, 251, 257, 263, 269, 283, 293, 307, 311, 313, 317], 1441) → 6 apr_9_2019_SLHL_recursiveSumCount([331, 337, 347, 349, 353, 359], 500) → 0 apr_9_2019_SLHL_recursiveSumCount([2, 3, 5, 7, 11, 13, 17, 19, 23], 111) → 0 ...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: 450
Copyright Nick Parlante 2017 - privacy