1 Star 41 Fork 18

小墨/力扣题库(完整版)

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
交点 [intersection-lcci].html 1.00 KB
一键复制 编辑 原始数据 按行查看 历史
小墨 提交于 2022-03-29 12:43 +08:00 . update
<p>给定两条线段(表示为起点<code>start = {X1, Y1}</code>和终点<code>end = {X2, Y2}</code>),如果它们有交点,请计算其交点,没有交点则返回空值。</p>
<p>要求浮点型误差不超过<code>10^-6</code>。若有多个交点(线段重叠)则返回 X 值最小的点,X 坐标相同则返回 Y 值最小的点。</p>
<p>&nbsp;</p>
<p><strong>示例 1:</strong></p>
<pre><strong>输入:</strong>
line1 = {0, 0}, {1, 0}
line2 = {1, 1}, {0, -1}
<strong>输出:</strong> {0.5, 0}
</pre>
<p><strong>示例 2:</strong></p>
<pre><strong>输入:</strong>
line1 = {0, 0}, {3, 3}
line2 = {1, 1}, {2, 2}
<strong>输出:</strong> {1, 1}
</pre>
<p><strong>示例 3:</strong></p>
<pre><strong>输入:</strong>
line1 = {0, 0}, {1, 1}
line2 = {1, 0}, {2, 1}
<strong>输出:</strong> {},两条线段没有交点
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li>坐标绝对值不会超过 2^7</li>
<li>输入的坐标均是有效的二维坐标</li>
</ul>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/coder-xiaomo/leetcode-problemset.git
git@gitee.com:coder-xiaomo/leetcode-problemset.git
coder-xiaomo
leetcode-problemset
力扣题库(完整版)
master

搜索帮助