Filter Odds and Reverse Evens
Updated
Problem statement
You are given an integer array nums.
Remove every odd value, then return the remaining even values in reverse order.
Function
filterOddsAndReverseEvens(nums: int[]) → int[] Complete the function filterOddsAndReverseEvens in the editor below.
filterOddsAndReverseEvens has the following parameter:
int[] nums: the input array
Returns int[]: the even values from nums, reversed.
Examples
Example 1
nums = [1, 2, 3, 4, 6]return = [6, 4, 2]After removing odd values, the remaining array is [2, 4, 6]. Reversing it gives [6, 4, 2].
Example 2
nums = [7, 9, 11]return = []Every value is odd, so the result is empty.
Constraints
1 <= nums.length <= 2 * 10^5-10^9 <= nums[i] <= 10^9
More Upstart Online Assessment questions
- Buffet Day GainsOA · Seen Sep 2026
- Case-Insensitive Anagram CheckOA · Seen Sep 2026
- Filter Duplicates While Preserving OrderOA · Seen Sep 2026
- Scale Ingredient QuantitiesOA · Seen Sep 2026
- ABO Parent Genotype CombinationsOA · Seen Aug 2026
- Chunked Byte Stream ChecksumsOA · Seen Aug 2026
- Cluster Size on DiskOA · Seen Aug 2026
- Double Substitution DecryptionOA · Seen Aug 2026
- Add Drama to Text GroupsOA · Seen Jul 2026
- Lexicographic Word FrequenciesOA · Seen Jul 2026
Similar questions at other companies
- Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Minimum Index Distance Between Person and CakeSnowflake · OA · PHONE SCREENSnowflake interview questions
- Meandering ArrayVerisk · OA
- Interleave Array HalvesAutodesk · OAAutodesk interview questions
- Collect Branches for a Bird NestVisa · OAVisa interview questions
- Maximum Requests in a Time WindowIBM · OAIBM interview questions
- Set IntersectionBlackRock · OABlackRock interview questions
- Can Every Package Fit in a BoxIMC Trading · OAIMC Trading interview questions
- Score Difference When Even Picks Reverse the ListMicrosoft · OAMicrosoft interview questions
- Maximum Events in a 60-Second WindowMarshall Wace · OAMarshall Wace interview questions