about | help | code help+videos | done | prefs |
Given a non-empty array of integers, recursively compute the largest value in the array. Note: You should solve this recursively (no loops). You will need a recursive helper method that takes an array and an index as parameters. Advice: If there are at least two items to look at, then do the following: look at the first number, and let recursion tell you the max of the rest of the numbers. Return whichever is bigger. Challenge: If you use Math.max() as part of your solution, you can solve this in 2 lines of code. max([3, 5, 1]) → 5 max([-2, 0, 4, 12]) → 12 max([8, 8, 8, 8, 8]) → 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