Tap here to switch tabs
Problem
Submissions

Problem: Subsequence of Size K With the Largest Even Sum

Try to solve the Subsequence of Size K With the Largest Even Sum problem.

Statement

You are given an integer array nums and an integer k. Find the maximum possible even sum of any subsequence of nums having a length of k.

Return the maximum even sum, or −1-1 if no such subsequence exists.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤105\leq 10^5

  • 1≤1 \leq k ≤\leq nums.length

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Subsequence of Size K With the Largest Even Sum

Try to solve the Subsequence of Size K With the Largest Even Sum problem.

Statement

You are given an integer array nums and an integer k. Find the maximum possible even sum of any subsequence of nums having a length of k.

Return the maximum even sum, or −1-1 if no such subsequence exists.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤105\leq 10^5

  • 1≤1 \leq k ≤\leq nums.length