Skip to content

Instantly share code, notes, and snippets.

@imhardiklakhani
Created February 3, 2021 05:51
Show Gist options
  • Save imhardiklakhani/31fcaf4acb4fc2daeb46d755cb4661c0 to your computer and use it in GitHub Desktop.
Save imhardiklakhani/31fcaf4acb4fc2daeb46d755cb4661c0 to your computer and use it in GitHub Desktop.
How do you find the largest and smallest number in an unsorted integer array?
//How do you find the largest and smallest number in an unsorted integer array?
fun main() {
val number = arrayOf(15, 24, 90, 4, 5, 1200, 8, 3, 47, 1, 45, 20)
println("Min ${number.minOrNull()}")
println("Max ${number.maxOrNull()}")
}
/*
OUTPUT:
Min 1
Max 1200
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment