3201
This commit is contained in:
13
src/3201.c
Normal file
13
src/3201.c
Normal 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));
|
||||
}
|
||||
Reference in New Issue
Block a user