博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
587. Erect the Fence
阅读量:4654 次
发布时间:2019-06-09

本文共 1076 字,大约阅读时间需要 3 分钟。

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:

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.

Solution:

This problem is the last question of leetcode weekly contest 32. It is pure math.

 

转载于:https://www.cnblogs.com/wdw828/p/6883938.html

你可能感兴趣的文章
css
查看>>
Web应用程序整体测试基础——单元测试
查看>>
通过修改manifest文件来解决Vista/Win7/Win8/win10下应用程序兼容性问题
查看>>
Spark使用总结与分享
查看>>
JMETER - BEANSHELL获取响应结果
查看>>
Line 7.10 : Syntax error
查看>>
[转] 树状数组学习
查看>>
ASP.NET-ActionFilter过滤器用法实例
查看>>
将url的查询参数解析成字典对象
查看>>
Redis与RabbitMQ作为消息队列的比较
查看>>
mybatis实战教程三:mybatis和springmvc整合
查看>>
Java多线程:Semaphore
查看>>
960栅格化优势
查看>>
LSP原则—关于正方形不是长方形
查看>>
Android内核开发 相关工具及源码下载汇总
查看>>
多线程(二)--NSThread基本使用
查看>>
git command
查看>>
使用Photon引擎进行unity网络游戏开发(二)——Photon常用类介绍
查看>>
html里 调整字间距
查看>>
RabbitMQ的Vhost,Exchange,Queue原理分析
查看>>