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)/检测相邻递增子数组 I [adjacent-increasing-subarrays-detection-i].html
2024-11-29 17:49:27 +08:00

47 lines
2.0 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>n</code> 个整数组成的数组 <code>nums</code> 和一个整数 <code>k</code>,请你确定是否存在 <strong>两个</strong> <strong>相邻</strong> 且长度为 <code>k</code><strong>严格递增</strong> 子数组。具体来说,需要检查是否存在从下标 <code>a</code><code>b</code> (<code>a &lt; b</code>) 开始的 <strong>两个</strong> 子数组,并满足下述全部条件:</p>
<ul>
<li>这两个子数组 <code>nums[a..a + k - 1]</code><code>nums[b..b + k - 1]</code> 都是 <strong>严格递增</strong> 的。</li>
<li>这两个子数组必须是 <strong>相邻的</strong>,即 <code>b = a + k</code></li>
</ul>
<p>如果可以找到这样的 <strong>两个</strong> 子数组,请返回 <code>true</code>;否则返回 <code>false</code></p>
<p><strong>子数组</strong> 是数组中的一个连续<b> 非空</b> 的元素序列。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong><span class="example-io">nums = [2,5,7,8,9,2,3,4,3,1], k = 3</span></p>
<p><strong>输出:</strong><span class="example-io">true</span></p>
<p><strong>解释:</strong></p>
<ul>
<li>从下标 <code>2</code> 开始的子数组为 <code>[7, 8, 9]</code>,它是严格递增的。</li>
<li>从下标 <code>5</code> 开始的子数组为 <code>[2, 3, 4]</code>,它也是严格递增的。</li>
<li>两个子数组是相邻的,因此结果为 <code>true</code></li>
</ul>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong><span class="example-io">nums = [1,2,3,4,4,4,4,5,6,7], k = 5</span></p>
<p><strong>输出:</strong><span class="example-io">false</span></p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>2 &lt;= nums.length &lt;= 100</code></li>
<li><code>1 &lt;= 2 * k &lt;= nums.length</code></li>
<li><code>-1000 &lt;= nums[i] &lt;= 1000</code></li>
</ul>