| about | help | code help+videos | done | prefs | 
getSmallest3_DifferentLengthsA
| public int getSmallest3_DifferentLengthsA(int[] nums)
 
public int getSmallest3_DifferentLengthsA(int[] nums) {
  int smallest = 0; // default if length == 0 (the empty array)
  int len = nums.length;
  if (len == 0) {
    smallest = 0; // NOT NECESSARY, because length == 0 is the default
  }
  if (len == 1) {
    smallest = nums[0];
  }
  if (len == 2) {
    smallest = Math.min( nums[0], nums[1] );
  }
  if (len == 3) {
    smallest = Math.min( nums[0], nums[1] );
    smallest = Math.min( smallest, nums[2] );
  }
  return smallest;
}
getSmallest3_DifferentLengthsA([]) → 0 getSmallest3_DifferentLengthsA([5]) → 5 getSmallest3_DifferentLengthsA([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