fun findMinMax(array: List<Int>): Pair<Int,Int> {
var min = array[0]
var max = array[0]
for (el in array) {
if (el < min) {
min = el
} else if (el > max) {
max = el
}
}
return Pair(min, max)
}
fun main() {
val array = listOf(3, 6, 1, 9, 10, 4, -4, 6, 12, 5, 11)
val (min, max) = findMinMax(array)
println("Minimum: $min, Maximum: $max")
}
ZnVuIGZpbmRNaW5NYXgoYXJyYXk6IExpc3Q8SW50Pik6IFBhaXI8SW50LEludD4gewogIHZhciBtaW4gPSBhcnJheVswXQogIHZhciBtYXggPSBhcnJheVswXQoKICBmb3IgKGVsIGluIGFycmF5KSB7CiAgICBpZiAoZWwgPCBtaW4pIHsKICAgICAgbWluID0gZWwKICAgIH0gZWxzZSBpZiAoZWwgPiBtYXgpIHsKICAgICAgbWF4ID0gZWwKICAgIH0KICB9CgogIHJldHVybiBQYWlyKG1pbiwgbWF4KQp9CgpmdW4gbWFpbigpIHsKICB2YWwgYXJyYXkgPSBsaXN0T2YoMywgNiwgMSwgOSwgMTAsIDQsIC00LCA2LCAxMiwgNSwgMTEpCgogIHZhbCAobWluLCBtYXgpID0gZmluZE1pbk1heChhcnJheSkKCiAgcHJpbnRsbigiTWluaW11bTogJG1pbiwgTWF4aW11bTogJG1heCIpCn0=