Implement Function to Determine Mode and Prime Numbers
Company: Amazon
Role: Data Scientist
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Overview: This question evaluates algorithmic problem-solving skills, including frequency analysis for mode computation, correct handling of ties and uniqueness edge cases, and basic number-theoretic competency for prime identification.
Constraints
- 0 <= len(nums) <= 200000
- -10^6 <= nums[i] <= 10^6
- Return modes as None if and only if every value appears once
- Return primes as unique values in ascending order
- 1 and negative numbers are not prime
Hints
- Use a frequency map (e.g., collections.Counter) to find the maximum frequency and all values that match it.
- If the maximum frequency is 1, return modes = None.
- To list primes efficiently, build a sieve up to the maximum positive value in nums and filter the unique values.
- Ignore values <= 1 for prime detection.