This commit is contained in:
2025-07-17 17:19:52 +08:00
parent 084c5f7e11
commit e3b069be8c
3 changed files with 62 additions and 0 deletions

13
src/3201.c Normal file
View File

@@ -0,0 +1,13 @@
#include <solution/3201.h>
#define max(x, y) ((x) > (y) ? (x) : (y))
int maximumLength(int *nums, int numsSize)
{
int odd = 0, even = 0, odd_cnt = 0;
for (int i = 0; i < numsSize; i++)
nums[i] & 1 ? (odd = even + 1, odd_cnt++) : (even = odd + 1);
return max(max(even, odd), max(odd_cnt, numsSize - odd_cnt));
}