about | help | code help+videos | done | prefs |
public int getSmallest2(int[] nums)
public int getSmallest2(int[] nums) { int smallest = nums[0]; if (nums[1] < smallest) { smallest = nums[1]; } return smallest; }Note: Another way to check for the smaller of two values is to use Math.min(): public int getSmallest2(int[] nums) { int smallest = Math.min( nums[0], nums[1] ); return smallest; } getSmallest2([5, 10]) → 5 getSmallest2([10, 5]) → 5 getSmallest2([3, 6]) → 3 ...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: 1
Copyright Nick Parlante 2017 - privacy