检测相邻递增子数组 I

bool hasIncreasingSubarrays(int* nums, int numsSize, int k) {
for (int i = 0; i <= numsSize - 2 * k; i++) {
bool increasing1 = true;
bool increasing2 = true;

for (int j = i; j < i + k - 1; j++) {
if (nums[j] >= nums[j + 1]) {
increasing1 = false;
break;
}
}

for (int j = i + k; j < i + 2 * k - 1; j++) {
if (nums[j] >= nums[j + 1]) {
increasing2 = false;
break;
}
}

if (increasing1 && increasing2) {
return true;
}
}
return false;
}

posted @ 2024-11-13 17:14  52H1Z  阅读(28)  评论(0)    收藏  举报