on 2D plane n point integer coordinate pointsi xi yi return minimum time second visit point order give pointsyou accord rulesIn 1 second eithermove vertically unitmove horizontally unit ormove diagonally sqrt2 unit word unit vertically unit horizontally 1 secondyou visit point order appear arrayyou allow pass point appear later order count visit Example 1input point 113410output 7explanation one optimal path 11 22 33 34 23 12 01 10 Time 11 34 3 second Time 34 10 4 secondstotal time 7 secondsexample 2input point 3222output 5 Constraintspointslength n1 n 100pointsilength 21000 pointsi0 pointsi1 1000