587. Erect the Fence
2017-05-21 09:13
295 查看
Problem statement:
There are some trees, where each tree is represented by (x,y) coordinate in a two-dimensional garden. Your job is 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. Your task is to help find the coordinates of trees which are exactly located on the fence perimeter.
Example 1:
Example 2:
Note:
All trees should be enclosed together. You cannot cut the rope to enclose trees that will separate them in more than one group.
All input integers will range from 0 to 100.
The garden has at least one tree.
All coordinates are distinct.
Input points have NO order. No order required for output.
Solution:
This problem is the last question of leetcode weekly contest 32. It is pure math.
There are some trees, where each tree is represented by (x,y) coordinate in a two-dimensional garden. Your job is 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. Your task is to help find the coordinates of trees which are exactly located on the fence perimeter.
Example 1:
Input: [[1,1],[2,2],[2,0],[2,4],[3,3],[4,2]] Output: [[1,1],[2,0],[4,2],[3,3],[2,4]] Explanation:
Example 2:
Input: [[1,2],[2,2],[4,2]] Output: [[1,2],[2,2],[4,2]] Explanation:
Even you only have trees in a line, you need to use rope to enclose them.
Note:
All trees should be enclosed together. You cannot cut the rope to enclose trees that will separate them in more than one group.
All input integers will range from 0 to 100.
The garden has at least one tree.
All coordinates are distinct.
Input points have NO order. No order required for output.
Solution:
This problem is the last question of leetcode weekly contest 32. It is pure math.
相关文章推荐
- 587. Erect the Fence
- leetcode 587. Erect the Fence 最短围栏 + 凸包优化
- [LeetCode] Erect the Fence 竖立栅栏
- (几何)LeetCode Weekly Contest 32 D-Erect the Fence
- NYOJ-Color the fence
- CF#202 div2 B Color the Fence
- nyoj 791 Color the fence(贪心)
- Color the fence
- nyoj 791——Color the fence——————【贪心】
- H - Color the Fence -贪心
- Color the fence
- Codeforces Round #202 (Div. 2) B. Color the Fence(贪心)
- Codeforces Round #202 (Div. 2)B. Color the Fence(贪心,模拟)
- 791 Color the fence
- Codeforces Round #202 (Div. 2)B. Color the Fence
- Codeforces 349 B Color the Fence (思维+贪心)
- Problem H. The Fence 通过取余判重,求得某个区间的某些个数为某个数的倍数。
- 南阳oj(nyoj) 791 Color the fence
- Color the fence
- nyoj color the fence