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

 

srp4379@lausd.net > findLargestVal
prev  |  next  |  chance

int findLargestVal(int[] nums). Given an array with a length between 0 and 5, examine its elements and return the LARGEST value you find. If the array has no elements, return 0.
Use Math.max(), which takes TWO (2) parameters, e.g.

    Math.max(30,60) returns 60
    Math.max(60,30) ALSO returns 60

Below is example code for finding the largest of the first 3 elements of an array.


    int largest = Math.max(nums[0], nums[1]);
    largest = Math.max(nums[2], largest);

findLargestVal([1, 3, 2]) → 3
findLargestVal([60, 50, 70, 90, 20]) → 90
findLargestVal([]) → 0

...Save, Compile, Run (ctrl-enter)

int findLargestVal(int[] nums) { }

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: 110

Copyright Nick Parlante 2017 - privacy