Created
February 3, 2021 05:51
-
-
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?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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