Exercise · Arrays and slices · lesson 9 of 10
Exercise: reversed slice
Write a function func reversed(nums []int) []int that returns a new slice with the elements of nums in reverse order. The function does not change the slice nums itself.
reversed([]int{1, 2, 3})→[3 2 1]reversed([]int{5})→[5]reversed([]int{})→[]
Constraints: nums holds from 0 to 1000 elements; for an empty slice the result is empty; after the call, nums holds the same elements in the same order.
Do not add extra imports unless the task says so explicitly.
Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.