1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/范围内整数的最大得分 [maximize-score-of-numbers-in-ranges].html
2024-09-19 09:27:23 +08:00

42 lines
1.6 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个整数数组 <code>start</code> 和一个整数 <code>d</code>,代表 <code>n</code> 个区间 <code>[start[i], start[i] + d]</code></p>
<p>你需要选择 <code>n</code> 个整数,其中第 <code>i</code> 个整数必须属于第 <code>i</code> 个区间。所选整数的 <strong>得分</strong> 定义为所选整数两两之间的 <strong>最小 </strong>绝对差。</p>
<p>返回所选整数的 <strong>最大可能得分 </strong></p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">start = [6,0,3], d = 2</span></p>
<p><strong>输出:</strong> <span class="example-io">4</span></p>
<p><strong>解释:</strong></p>
<p>可以选择整数 8, 0 和 4 获得最大可能得分,得分为 <code>min(|8 - 0|, |8 - 4|, |0 - 4|)</code>,等于 4。</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">start = [2,6,13,13], d = 5</span></p>
<p><strong>输出:</strong> <span class="example-io">5</span></p>
<p><strong>解释:</strong></p>
<p>可以选择整数 2, 7, 13 和 18 获得最大可能得分,得分为 <code>min(|2 - 7|, |2 - 13|, |2 - 18|, |7 - 13|, |7 - 18|, |13 - 18|)</code>,等于 5。</p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>2 &lt;= start.length &lt;= 10<sup>5</sup></code></li>
<li><code>0 &lt;= start[i] &lt;= 10<sup>9</sup></code></li>
<li><code>0 &lt;= d &lt;= 10<sup>9</sup></code></li>
</ul>