mirror of
https://github.com/lWolvesl/leetcode.git
synced 2026-02-27 03:38:08 +08:00
3379, 3650
This commit is contained in:
11
26/01/go/3650.go
Normal file
11
26/01/go/3650.go
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package A
|
||||||
|
|
||||||
|
func minCost(n int, edges [][]int) int {
|
||||||
|
edgeM := make([][]int, n)
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
edgeM[i] = make([]int, n)
|
||||||
|
}
|
||||||
|
for _, e := range edges {
|
||||||
|
edgeM[e[0]][e[1]] = e[2]
|
||||||
|
}
|
||||||
|
}
|
||||||
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