Pair Elements with Even Sums
Updated
Problem statement
You are given an integer array numbers. Pair every element with exactly one other element so that the sum of the two numbers in every pair is even.
Return "YES" if such a complete pairing exists. Otherwise, return "NO".
Function
canPairWithEvenSums(numbers: int[]) → StringExamples
Example 1
numbers = [1,3,2,4]return = "YES"Pair 1 with 3 and 2 with 4. Both sums are even.
Example 2
numbers = [1,2]return = "NO"The only possible pair has sum 3, which is odd.
Example 3
numbers = [5,7,9,2]return = "NO"There are three odd values and one even value. One odd value would have to be paired with an even value, producing an odd sum.
Constraints
1 <= numbers.length <= 100000-10^9 <= numbers[i] <= 10^9
More Deloitte Online Assessment questions
- Seventh Nearest PalindromeOA · Seen May 2026
- Minimum Deletions for a Non-PalindromeOA · Seen Jul 2025
- Minimum-Cost Solar Rooftop AllocationOA · Seen Jul 2025
- Count Divisible PermutationsOA · Seen Jan 2025
- Largest Element in an ArrayOA · Seen Nov 2024
- Install Carbon FiltersOA · Seen Oct 2023
- Longest Substring with Even OccurrencesOA · Seen Oct 2023
- Maximum Sum RectangleOA · Seen Apr 2022
- Annual Bank Balance with Monthly Card FeesOA · Seen Jan 2022
- Count Battleships by SizeOA · Seen Jan 2022
Similar questions at other companies
- Count Valid Square PairsAuxoAI · OA
- Picked Player Who LostSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Server InvestmentRippling · OARippling interview questions
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Next Pascal Row CoefficientIntuit · OAIntuit interview questions
- Unique Integers That Sum to ZeroNVIDIA · OANVIDIA interview questions
- Count Multiples of Three with Two SevensHudson River Trading · OAHudson River Trading interview questions
- Diagonal Bounce TraversalAutodesk · OAAutodesk interview questions
- Maximum Student-Teacher DistanceChubb · OAChubb interview questions
- Maximum Three-Server Difficulty ScoreVisa · OAVisa interview questions