id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > apr_9_2019_SLHL_recursiveSumCount
prev  |  next  |  chance

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)

public int apr_9_2019_SLHL_recursiveSumCount(int[] nums, int target) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 450

Copyright Nick Parlante 2017 - privacy