添加新题目

This commit is contained in:
2025-08-21 19:04:30 +08:00
parent 2eb2d2bedc
commit 1f832e271e
8 changed files with 514 additions and 23 deletions

View File

@@ -0,0 +1,16 @@
package main
func main() {
rotate([]int{1, 2, 3, 4, 5, 6, 7}, 3)
}
func rotate(nums []int, k int) {
temp := make([]int, len(nums))
for i := 0; i < len(nums); i++ {
target := (i + k) % len(nums)
temp[target] = nums[i]
}
for i := 0; i < len(nums); i++ {
nums[i] = temp[i]
}
}