elma_developer_test/rotation/rotation.go

14 lines
304 B
Go
Raw Permalink Normal View History

// Циклическая ротация
2022-09-16 00:40:14 +03:00
package rotation
func Rotation(A []int, K int) []int {
for i := 0; i < K; i++ {
2022-09-16 13:48:36 +03:00
//A[len(A)-1:] - последний элемент; A[:len(A)-1] - все элементы до последнего
2022-09-16 00:40:14 +03:00
A = append(A[len(A)-1:], A[:len(A)-1]...)
}
return A
}