fun reverse(numbers: List<Int>): List<Int> { var res = arrayListOf<Int>() for (i in 0..numbers.size-1) { res.add(numbers.get(numbers.size - 1 - i)) } return res } fun reverse2(numbers: List<Int>): List<Int> { var res = arrayListOf<Int>() for (i in numbers.size - 1 downTo 0) { res.add(numbers.get(i)) } return res } fun main() { val numbers = listOf(1,2,4,6,7,8) val res = reverse(numbers) val res2 = reverse2(numbers) println(res) // [8, 7, 6, 4, 2, 1] println(res2) // [8, 7, 6, 4, 2, 1] }