mirror of
https://github.com/lWolvesl/leetcode.git
synced 2026-02-27 11:58:39 +08:00
3379, 3650
This commit is contained in:
18
26/02/3379.go
Normal file
18
26/02/3379.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package A
|
||||
|
||||
func constructTransformedArray(nums []int) []int {
|
||||
n := len(nums)
|
||||
res := make([]int, n)
|
||||
for i, v := range nums {
|
||||
if v > 0 {
|
||||
res[i] = nums[(i+v)%n]
|
||||
}
|
||||
if v == 0 {
|
||||
res[i] = v
|
||||
}
|
||||
if v < 0 {
|
||||
res[i] = nums[((i+v)%n+n)%n]
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
Reference in New Issue
Block a user