classSolution { publicbooleanhasIncreasingSubarrays(TreeSet<Integer> set, int n, int k) { // int n = nums.size(); for (inti=0; i < n; i++) { intnxt= i+k; if (nxt >= n) break; intc1= (int)set.higher(i), c2 = (int)set.higher(nxt); if (c1 - i >= k && c2 - nxt >= k) returntrue; } returnfalse; } publicintmaxIncreasingSubarrays(List<Integer> nums) { intn= nums.size(); TreeSet<Integer> set = newTreeSet<>(); for (inti=1; i < n; i++) { if (nums.get(i) <= nums.get(i-1)) { set.add(i); // 5, 8, 9 } } set.add(n); intl=0, r = n/2+1; while (l < r) { intmid= l + (r-l)/2; if (hasIncreasingSubarrays(set, n, mid)) l = mid+1; else r = mid; } return l-1; } }