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

 

apcsaArraysFindMinArrayValue


Given an unsorted array of ints, find and return the minimum of the numbers in the array (i.e. the smallest value).


Think of how you might solve this as a human, presented with a whole book full of numbers and told to find the smallest number.  Then, a wrinkle: what if you didn't get to see the book (lots of numbers at a time) but someone else could read you one number at a time, in sequence?

When they read you the first number, is that the lowest number you have seen so far? Then, with each number after that: does it get compared in your mind to the previous number?  Or does it get compared to something else?  If you are in the middle of getting the book read to you, do you know the smallest number you have seen so far?  Is it possible to answer the question before getting to the last number?

This problem is a very good demonstration of why it's a good idea to create an output variable first, and give it an appropriate
starting value.

apcsaArraysFindMinArrayValue([0, 1, 2, 3]) → 0
apcsaArraysFindMinArrayValue([-1, -3, 5]) → -3
apcsaArraysFindMinArrayValue([0]) → 0

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

public int apcsaArraysFindMinArrayValue(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: 220

Copyright Nick Parlante 2017 - privacy