587. Erect the Fence Hard
1/**
2 * [587] Erect the Fence
3 *
4 * You are given an array trees where trees[i] = [xi, yi] represents the location of a tree in the garden.
5 * You are asked to fence the entire garden using the minimum length of rope as it is expensive. The garden is well fenced only if all the trees are enclosed.
6 * Return the coordinates of trees that are exactly located on the fence perimeter.
7 *
8 * Example 1:
9 * <img alt="" src="https://assets.leetcode.com/uploads/2021/04/24/erect2-plane.jpg" style="width: 509px; height: 500px;" />
10 * Input: points = [[1,1],[2,2],[2,0],[2,4],[3,3],[4,2]]
11 * Output: [[1,1],[2,0],[3,3],[2,4],[4,2]]
12 *
13 * Example 2:
14 * <img alt="" src="https://assets.leetcode.com/uploads/2021/04/24/erect1-plane.jpg" style="width: 509px; height: 500px;" />
15 * Input: points = [[1,2],[2,2],[4,2]]
16 * Output: [[4,2],[2,2],[1,2]]
17 *
18 *
19 * Constraints:
20 *
21 * 1 <= points.length <= 3000
22 * points[i].length == 2
23 * 0 <= xi, yi <= 100
24 * All the given points are unique.
25 *
26 */
27pub struct Solution {}
28
29// problem: https://leetcode.com/problems/erect-the-fence/
30// discuss: https://leetcode.com/problems/erect-the-fence/discuss/?currentPage=1&orderBy=most_votes&query=
31
32// submission codes start here
33
34impl Solution {
35 pub fn outer_trees(trees: Vec<Vec<i32>>) -> Vec<Vec<i32>> {
36 vec![]
37 }
38}
39
40// submission codes end
41
42#[cfg(test)]
43mod tests {
44 use super::*;
45
46 #[test]
47 fn test_587() {
48 }
49}
50
Back
© 2025 bowen.ge All Rights Reserved.