Back to problems

Reverse even numbers in a list

Algorithm · Upstart · Easy

Given an integer array nums, return a new array that contains only the even values from nums, arranged in the opposite of their original order. Equivalently, inspect the array starting at the last index and move toward index 0, appending each even element to the result as it is encountered. Odd elements are skipped. Treat 0 and every negative multiple of 2 as even. Keep all occurrences of an even value, including duplicates. If the array contains no even values, return an…

Checking your access…