3350. Adjacent Increasing Subarrays Detection II Medium
1/**
2 * [3350] Adjacent Increasing Subarrays Detection II
3 *
4 * Given an array nums of n integers, your task is to find the maximum value of k for which there exist two adjacent <span data-keyword="subarray-nonempty">subarrays</span> of length k each, such that both subarrays are strictly increasing. Specifically, check if there are two subarrays of length k starting at indices a and b (a < b), where:
5 *
6 * Both subarrays nums[a..a + k - 1] and nums[b..b + k - 1] are strictly increasing.
7 * The subarrays must be adjacent, meaning b = a + k.
8 *
9 * Return the maximum possible value of k.
10 * A subarray is a contiguous non-empty sequence of elements within an array.
11 *
12 * <strong class="example">Example 1:
13 * <div class="example-block">
14 * Input: <span class="example-io">nums = [2,5,7,8,9,2,3,4,3,1]</span>
15 * Output: <span class="example-io">3</span>
16 * Explanation:
17 *
18 * The subarray starting at index 2 is [7, 8, 9], which is strictly increasing.
19 * The subarray starting at index 5 is [2, 3, 4], which is also strictly increasing.
20 * These two subarrays are adjacent, and 3 is the maximum possible value of k for which two such adjacent strictly increasing subarrays exist.
21 * </div>
22 * <strong class="example">Example 2:
23 * <div class="example-block">
24 * Input: <span class="example-io">nums = [1,2,3,4,4,4,4,5,6,7]</span>
25 * Output: <span class="example-io">2</span>
26 * Explanation:
27 *
28 * The subarray starting at index 0 is [1, 2], which is strictly increasing.
29 * The subarray starting at index 2 is [3, 4], which is also strictly increasing.
30 * These two subarrays are adjacent, and 2 is the maximum possible value of k for which two such adjacent strictly increasing subarrays exist.
31 * </div>
32 *
33 * Constraints:
34 *
35 * 2 <= nums.length <= 2 * 10^5
36 * -10^9 <= nums[i] <= 10^9
37 *
38 */
39pub struct Solution {}
40
41// problem: https://leetcode.com/problems/adjacent-increasing-subarrays-detection-ii/
42// discuss: https://leetcode.com/problems/adjacent-increasing-subarrays-detection-ii/discuss/?currentPage=1&orderBy=most_votes&query=
43
44// submission codes start here
45
46impl Solution {
47 pub fn max_increasing_subarrays(nums: Vec<i32>) -> i32 {
48 0
49 }
50}
51
52// submission codes end
53
54#[cfg(test)]
55mod tests {
56 use super::*;
57
58 #[test]
59 fn test_3350() {
60 }
61}
62
Back
© 2025 bowen.ge All Rights Reserved.