3350. 检测相邻递增子数组 II
题目链接:https://leetcode.cn/problems/adjacent-increasing-subarrays-detection-ii/
题解代码:
int maxIncreasingSubarrays(int* nums, int numsSize) {
int ans = 0, pre_cnt = 0,cnt=0;
for(int i=0;i<numsSize;i++){
cnt++;
if(i==numsSize-1||nums[i]>=nums[i+1]){
int min_ = (pre_cnt>cnt) ?cnt:pre_cnt,
max_ = (ans > cnt/2) ? ans : cnt/2;
ans = (max_ >min_ ) ? max_ : min_;
pre_cnt =cnt;
cnt=0;
}
}
return ans;
}