package main
import "fmt"
func rotateRightByOne(arr []int) []int {
n := len(arr)
if n == 0 {
return arr
}
// Store the last element
last := arr[n - 1]
// Shift elements to the right
for i := n - 1; i > 0; i-- {
arr[i] = arr[i - 1]
}
// Place the last element at the first position
arr[0] = last
return arr
}
func main() {
arr := []int{3, 0, 8, 5, 7}
rotatedArr := rotateRightByOne(arr)
fmt.Println("Rotated array:", rotatedArr)
}
/*
run:
Rotated array: [7 3 0 8 5]
*/