FastPrepMaximum Even Subsequence Sum
Problems/Maximum Even Subsequence Sum

Maximum Even Subsequence Sum

Expedia logoExpedia● MediumINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Two reports from Expedia's internship online assessment describe this task. One gives only a short summary. The other shows the full assessment prompt in screenshots. The tag values can be negative, you may choose no tags, at least one value is even, and the array holds 1 to 10^5 values from -10^9 to 10^9. It also shows a worked example and two sample cases. This page follows that full prompt. We chose the function name, the parameter name, the wording, and our own visible examples. The report's example and sample cases are among the hidden tests. Our version is about 97% the same as the full prompt.

You are given an integer array nums. Each value is the value of one discount tag, and values can be negative. Choose some of the tags so that the sum of the chosen values is even. Return the largest even sum you can get.

  • You may choose no tags at all. That choice has sum 0, and zero counts as even.
  • The chosen tags do not have to be next to each other.
  • You return only the sum, not the chosen tags.

At least one value in nums is even.

Function

maxEvenSubsequenceSum(nums: int[]) → long

Examples

Example 1

nums = [4,7,2,-5,3]return = 16

The positive values add up to 4 + 7 + 2 + 3 = 16, which is even. Adding -5 would only lower the sum, so it stays out. The value 3 is not next to the other chosen values, and that is allowed.

Example 2

nums = [6,3,-1]return = 8

The positive values add up to 9, which is odd, so something has to change. Removing 3 gives 6. Adding -1 gives 8. The larger even sum is 8.

Example 3

nums = [6,3,-5]return = 6

The positive values add up to 9 again. This time adding -5 gives only 4, while removing 3 gives 6. The answer is 6.

Example 4

nums = [-3,-8,-1]return = 0

Every value is negative, so adding any tag lowers the sum. The best choice is to take no tags, which gives 0.

Example 5

nums = [3,-4,-9]return = 0

The only positive value, 3, is odd. Adding -9 to it gives -6. Removing 3 leaves no tags chosen, which is allowed and gives 0. The answer is 0.

Constraints

  • 1 <= nums.length <= 10^5
  • -10^9 <= nums[i] <= 10^9
  • At least one value in nums is even.

More Expedia Online Assessment questions

  • Balanced NumbersOA · Seen Aug 2026
  • REST API: Discounted PriceOA · Seen Aug 2026
  • Maximum Team SizeOA · Seen Mar 2026
  • Per-Domain Request LimiterOA · Seen Oct 2025
  • Count Equal-Frequency SubsequencesOA · Seen Mar 2025
  • Count Increasing Stock PeriodsOA · Seen Mar 2025
  • Get Minimum StepsOA · Seen Oct 2024
  • Rank Songs by PopularityOA · Seen Oct 2024
  • Calculate the SumOA · Seen Oct 2024
  • Get Maximum EfficiencyOA · Seen Oct 2024

Similar questions at other companies

  • Maximum Even-Sum Neighboring PairsDRW · OADRW interview questions
  • Minimize Total Input Cost (for LTMS)Salesforce · OASalesforce interview questions
  • Maximize Protected City PopulationAmazon · OA
  • Network FormationPalantir · OAPalantir interview questions
  • Maximum Even-Sum Adjacent Pairs in a Circular ArrayTesla · OATesla interview questions
  • Fewest Fountains to Water the GardenDocuSign · OADocuSign interview questions
  • Minimum Jumps to Reach the EndNutanix · OANutanix interview questions
  • Split Array to Minimize the Largest SumInfosys · OAInfosys interview questions
  • Split Array Largest SumAuxoAI · OA
  • Maximum Income from Asset TradingJefferies · OA

Expedia interview experiences

  • Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
  • Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
  • Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
  • Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
  • Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)
  • Expedia SWE Intern Final Round: 126 Experiences (Part 1 of 6)
All Expedia interview questionsSee Expedia hiring insights
Saved
class Solution {
    public long maxEvenSubsequenceSum(int[] nums) {
        // Write your code here.
    }
}
Checking account…