Decode an anagram sentence using vocabulary constraints
Company: Upstart
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates string manipulation, anagram detection, and constrained dictionary mapping skills, testing attention to character-level constraints and correct disambiguation among similar vocabulary entries.
Part 1: Reverse a Number List While Filtering Out Odd Numbers
Constraints
- 0 <= len(nums) <= 100000
- -10^9 <= nums[i] <= 10^9
Examples
Input: ([2, 3, 4],)
Expected Output: [4, 2]
Explanation: The even numbers are 2 and 4, and they appear in reverse order.
Input: ([-3, -2, -1, 0, 5, 8],)
Expected Output: [8, 0, -2]
Explanation: Only -2, 0, and 8 are even, and the result must be reversed.
Input: ([],)
Expected Output: []
Explanation: An empty list has no even numbers.
Input: ([7],)
Expected Output: []
Explanation: The single element is odd, so nothing remains.
Hints
- Try iterating from the end of the list instead of reversing first and then filtering.
- Remember that negative even numbers also satisfy x % 2 == 0.