|
| 1 | +<h2><a href="https://leetcode.com/problems/adjacent-increasing-subarrays-detection-i/">3349. Adjacent Increasing Subarrays Detection I</a></h2><h3>Easy</h3><hr><div><p>Given an array <code>nums</code> of <code>n</code> integers and an integer <code>k</code>, determine whether there exist <strong>two</strong> <strong>adjacent</strong> <span data-keyword="subarray-nonempty">subarrays</span> of length <code>k</code> such that both subarrays are <strong>strictly</strong> <strong>increasing</strong>. Specifically, check if there are <strong>two</strong> subarrays starting at indices <code>a</code> and <code>b</code> (<code>a < b</code>), where:</p> |
| 2 | + |
| 3 | +<ul> |
| 4 | + <li>Both subarrays <code>nums[a..a + k - 1]</code> and <code>nums[b..b + k - 1]</code> are <strong>strictly increasing</strong>.</li> |
| 5 | + <li>The subarrays must be <strong>adjacent</strong>, meaning <code>b = a + k</code>.</li> |
| 6 | +</ul> |
| 7 | + |
| 8 | +<p>Return <code>true</code> if it is <em>possible</em> to find <strong>two </strong>such subarrays, and <code>false</code> otherwise.</p> |
| 9 | + |
| 10 | +<p> </p> |
| 11 | +<p><strong class="example">Example 1:</strong></p> |
| 12 | + |
| 13 | +<div class="example-block"> |
| 14 | +<p><strong>Input:</strong> <span class="example-io">nums = [2,5,7,8,9,2,3,4,3,1], k = 3</span></p> |
| 15 | + |
| 16 | +<p><strong>Output:</strong> <span class="example-io">true</span></p> |
| 17 | + |
| 18 | +<p><strong>Explanation:</strong></p> |
| 19 | + |
| 20 | +<ul> |
| 21 | + <li>The subarray starting at index <code>2</code> is <code>[7, 8, 9]</code>, which is strictly increasing.</li> |
| 22 | + <li>The subarray starting at index <code>5</code> is <code>[2, 3, 4]</code>, which is also strictly increasing.</li> |
| 23 | + <li>These two subarrays are adjacent, so the result is <code>true</code>.</li> |
| 24 | +</ul> |
| 25 | +</div> |
| 26 | + |
| 27 | +<p><strong class="example">Example 2:</strong></p> |
| 28 | + |
| 29 | +<div class="example-block"> |
| 30 | +<p><strong>Input:</strong> <span class="example-io">nums = [1,2,3,4,4,4,4,5,6,7], k = 5</span></p> |
| 31 | + |
| 32 | +<p><strong>Output:</strong> <span class="example-io">false</span></p> |
| 33 | +</div> |
| 34 | + |
| 35 | +<p> </p> |
| 36 | +<p><strong>Constraints:</strong></p> |
| 37 | + |
| 38 | +<ul> |
| 39 | + <li><code>2 <= nums.length <= 100</code></li> |
| 40 | + <li><code>1 < 2 * k <= nums.length</code></li> |
| 41 | + <li><code>-1000 <= nums[i] <= 1000</code></li> |
| 42 | +</ul> |
| 43 | +</div> |
0 commit comments