xxxxxxxxxx
fun max(map:Map<Int,String>) = map.maxByOrNull { it.key }?.key ?:-1//returns negative one if the max is null
fun main(){
var map = mapOf(1 to "hello",2 to "peace", 3 to "ochuko")
println(map.maxByOrNull { it.key }?.key ?:-1)
}
xxxxxxxxxx
//For kotlin
fun max(map:Map<Int,String>) = map.maxByOrNull { it.key }?.key ?:-1//returns negative one if the max is null
fun main(){
var map = mapOf(1 to "hello",2 to "peace", 3 to "ochuko")
println(map.maxByOrNull { it.key }?.key ?:-1)
}