about | help | code help+videos | done | prefs |
Write a method that returns 'true' if it is possible to obtain the 'target' sum by selecting any number of elements from the array 'nums'. If it is not possible, return 'false'. There may be more than one way to obtain the sum, but that doesn't matter. You just need to return 'true' if it is possible and 'false' if it is not. This problem is easily solved using backtrack recursion, but that is NOT required. The array 'nums' will be short enough that you should not have problems with timing out unless you have horrible efficiency. quiz2020_12_15_HL_targetSum([7379, 8586, 8603, 8620, 8637, 8654, 8671, 8688, 8705, 8722, 8739, 8756, 8773, 8790, 9011, 9028, 9216, 9963, 9980, 9997], 9195) → false quiz2020_12_15_HL_targetSum([487, 9504, 9521, 9536, 9793, 9810, 9827, 9844, 9861, 9878, 9895, 9912, 9929, 9946, 9963, 9980, 9997], 17019) → false quiz2020_12_15_HL_targetSum([5203, 5220, 5237, 5254, 9946, 9963, 9980, 9997], 9963) → true ...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: 440
Copyright Nick Parlante 2017 - privacy