File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 271227123342|[ Find Minimum Time to Reach Last Room II] ( ./solutions/3342-find-minimum-time-to-reach-last-room-ii.js ) |Medium|
271327133343|[ Count Number of Balanced Permutations] ( ./solutions/3343-count-number-of-balanced-permutations.js ) |Hard|
271427143344|[ Maximum Sized Array] ( ./solutions/3344-maximum-sized-array.js ) |Medium|
2715+ 3349|[ Adjacent Increasing Subarrays Detection I] ( ./solutions/3349-adjacent-increasing-subarrays-detection-i.js ) |Easy|
271527163353|[ Minimum Total Operations] ( ./solutions/3353-minimum-total-operations.js ) |Easy|
271627173355|[ Zero Array Transformation I] ( ./solutions/3355-zero-array-transformation-i.js ) |Medium|
271727183356|[ Zero Array Transformation II] ( ./solutions/3356-zero-array-transformation-ii.js ) |Medium|
Original file line number Diff line number Diff line change 1+ /**
2+ * 3349. Adjacent Increasing Subarrays Detection I
3+ * https://leetcode.com/problems/adjacent-increasing-subarrays-detection-i/
4+ * Difficulty: Easy
5+ *
6+ * Given an array nums of n integers and an integer k, determine whether there exist two
7+ * adjacent subarrays of length k such that both subarrays are strictly increasing.
8+ * Specifically, check if there are two subarrays starting at indices a and b (a < b),
9+ * where:
10+ * - Both subarrays nums[a..a + k - 1] and nums[b..b + k - 1] are strictly increasing.
11+ * - The subarrays must be adjacent, meaning b = a + k.
12+ *
13+ * Return true if it is possible to find two such subarrays, and false otherwise.
14+ */
15+
16+ /**
17+ * @param {number[] } nums
18+ * @param {number } k
19+ * @return {boolean }
20+ */
21+ var hasIncreasingSubarrays = function ( nums , k ) {
22+ for ( let i = 0 ; i <= nums . length - 2 * k ; i ++ ) {
23+ if ( helper ( i , k ) && helper ( i + k , k ) ) {
24+ return true ;
25+ }
26+ }
27+
28+ return false ;
29+
30+ function helper ( start , length ) {
31+ for ( let i = start ; i < start + length - 1 ; i ++ ) {
32+ if ( nums [ i ] >= nums [ i + 1 ] ) return false ;
33+ }
34+ return true ;
35+ }
36+ } ;
You can’t perform that action at this time.
0 commit comments