2242. Subsequence of Size K With the Largest Even Sum

Medium
Array
Greedy
Sorting

Description

Hints

Hint 1
Is the sum of two even numbers even or odd? How about two odd numbers? One odd number and one even number?
Hint 2
If there is an even number of odd numbers, the sum will be even and vice versa.
Hint 3
Create an integer array to store all the even numbers in nums and another array to store all the odd numbers in nums. Sort both arrays.

Statistics

Acceptance
35.8%
Submissions
13,065
Accepted
4,679