Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/neetcode-gh/leetcode
/ rotate
Function
rotate
go/0189-rotate-array.go:1–6 ·
view source on GitHub ↗
(nums []int, k int)
Source
from the content-addressed store, hash-verified
1
func
rotate(nums []int, k int) {
2
k = k % len(nums)
3
reverse(nums, 0, len(nums) - 1)
4
reverse(nums, 0, k - 1)
5
reverse(nums, k, len(nums) - 1)
6
}
7
8
func
reverse(nums []int, start, end int) {
9
for
start <= end {
Callers
nothing calls this directly
Calls
1
reverse
Function · 0.70
Tested by
no test coverage detected