cswork / OA打开练习工作台

UpstartOA #2

Filter Odds and Reverse Evens

估计简单评测数据准备中,可先阅读题面

考点(AI 标注)原地数组

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.