Hexa
12/20/2018, 11:26 PMmap
function but I have no idea how to keep track of smallest
and largest
like I do in a regular for loop: fun testFun(nums: IntArray): Int {
var smallest = nums[0]
var largest = nums[0]
for (i in nums.indices) {
smallest = Math.min(smallest, nums[i])
largest = Math.max(largest, nums[i])
}
return largest - smallest
}