[leetcode]Geometry-587. Erect the Fence

Posted chenhan05

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[leetcode]Geometry-587. Erect the Fence相关的知识,希望对你有一定的参考价值。

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: 

  1. All trees should be enclosed together. You cannot cut the rope to enclose trees that will separate them in more than one group.
  2. All input integers will range from 0 to 100. 
  3. The garden has at least one tree. 
  4. All coordinates are distinct. 
  5. Input points have NO order. No order required for output.

 

/**
 * Definition for a point.
 * struct Point {
 *     int x;
 *     int y;
 *     Point() : x(0), y(0) {}
 *     Point(int a, int b) : x(a), y(b) {}
 * };
 */
class Solution {
public:
    vector<Point> outerTrees(vector<Point>& points) {
        
    }
};

 

以上是关于[leetcode]Geometry-587. Erect the Fence的主要内容,如果未能解决你的问题,请参考以下文章

Leetcode 65 Valid Number

leetcode-13双周赛-1256-加密数字

leetcode223

LeetCode 79.单词搜索

LeetCode79:单词搜索

Leetcode 79.单词搜索