UpstartOA #2
Filter Odds and Reverse Evens
Estimated EasyStatement and editorial — judging is being prepared
Topics (AI-labelled)In-place Arrays
You are given an integer array nums.
<p cl
Constraints
1 ≤ nums.length ≤ 2 * 10⁵-10⁹ ≤ nums[i] ≤ 10⁹
Example 1
Input:
nums = [1, 2, 3, 4, 6]
Output:
[6, 4, 2]
Explanation:
After removing odd values, the remaining array is [2, 4, 6]. Reversing it gives [6, 4, 2].
Example 2
Input:
nums = [7, 9, 11]
Output:
[]
Explanation: Every value is odd, so the result is empty.
Editorial
Loading solution…