Kotlin newbie here, I'm trying to Write a program that finds the minimum value of N numbers. The first line contains the number N. The second line contains N numbers separated by spaces. Output an integer number which is the minimum of N numbers. So far I'm getting a null error, so I know the problem is in adding numbers to the array. Here is my code:
fun main(args: Array<String>) {
val scanner = Scanner(System.`in`)
val num1: Int = scanner.nextInt()
var nums = arrayListOf<Int>()
val smallestElement = nums.min()
repeat (num1) {
nums.add(scanner.nextInt())
}
println(smallestElement)
}