add new solutions

This commit is contained in:
kanna5 2026-01-05 16:48:03 +09:00
parent ca24d0a56a
commit 0c73608ce5
Signed by: kkyy
GPG key ID: 06332F3965E9B0CF
36 changed files with 791 additions and 0 deletions

View file

@ -0,0 +1,20 @@
package q1226
func abs(i int) int {
if i < 0 {
return -i
}
return i
}
func minTimeToVisitAllPoints(points [][]int) int {
time := 0
for i := 0; i < len(points)-1; i++ {
cur, next := points[i], points[i+1]
dx, dy := abs(cur[0]-next[0]), abs(cur[1]-next[1])
time += max(dx, dy)
}
return time
}
var _ = minTimeToVisitAllPoints