1266. Minimum Time Visiting All Points Easy

@problem@discussion
#Array#Math#Geometry



1/**
2 * [1266] Minimum Time Visiting All Points
3 *
4 * On a 2D plane, there are n points with integer coordinates points[i] = [xi, yi]. Return the minimum time in seconds to visit all the points in the order given by points.
5 * You can move according to these rules:
6 * 
7 * 	In 1 second, you can either:
8 * 	
9 * 		move vertically by one unit,
10 * 		move horizontally by one unit, or
11 * 		move diagonally sqrt(2) units (in other words, move one unit vertically then one unit horizontally in 1 second).
12 * 	
13 * 	
14 * 	You have to visit the points in the same order as they appear in the array.
15 * 	You are allowed to pass through points that appear later in the order, but these do not count as visits.
16 * 
17 *  
18 * Example 1:
19 * <img alt="" src="https://assets.leetcode.com/uploads/2019/11/14/1626_example_1.PNG" style="width: 500px; height: 428px;" />
20 * Input: points = [[1,1],[3,4],[-1,0]]
21 * Output: 7
22 * Explanation: One optimal path is [1,1] -> [2,2] -> [3,3] -> [3,4] -> [2,3] -> [1,2] -> [0,1] -> [-1,0]   
23 * Time from [1,1] to [3,4] = 3 seconds 
24 * Time from [3,4] to [-1,0] = 4 seconds
25 * Total time = 7 seconds
26 * Example 2:
27 * 
28 * Input: points = [[3,2],[-2,2]]
29 * Output: 5
30 * 
31 *  
32 * Constraints:
33 * 
34 * 	points.length == n
35 * 	1 <= n <= 100
36 * 	points[i].length == 2
37 * 	-1000 <= points[i][0], points[i][1] <= 1000
38 * 
39 */
40pub struct Solution {}
41
42// problem: https://leetcode.com/problems/minimum-time-visiting-all-points/
43// discuss: https://leetcode.com/problems/minimum-time-visiting-all-points/discuss/?currentPage=1&orderBy=most_votes&query=
44
45// submission codes start here
46
47impl Solution {
48    pub fn min_time_to_visit_all_points(points: Vec<Vec<i32>>) -> i32 {
49        0
50    }
51}
52
53// submission codes end
54
55#[cfg(test)]
56mod tests {
57    use super::*;
58
59    #[test]
60    fn test_1266() {
61    }
62}
63


Back
© 2025 bowen.ge All Rights Reserved.