PracHub
QuestionsLearningGuidesInterview Prep

Quick 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.

  • medium
  • Amazon
  • Coding & Algorithms
  • Data Scientist

Implement Function to Determine Mode and Prime Numbers

Company: Amazon

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

##### Scenario Implementing utility algorithms within a data-processing library. ##### Question Write a function that returns the mode of an integer list; if all values are unique return None, and support multiple modes when ties exist. Given an integer array containing 1 to n, output all prime numbers in the array. ##### Hints Emphasize time complexity and edge-case handling.

Quick Answer: 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.

Given an integer array nums, implement analyze_numbers(nums) that returns a 2-element list: [modes, primes]. modes is either None (if all values in nums appear exactly once) or a sorted list of all values that have the maximum frequency (support ties). primes is a sorted list of unique prime numbers present in nums (values > 1 only). If nums is empty, return [None, []].

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

  1. Use a frequency map (e.g., collections.Counter) to find the maximum frequency and all values that match it.
  2. If the maximum frequency is 1, return modes = None.
  3. To list primes efficiently, build a sieve up to the maximum positive value in nums and filter the unique values.
  4. Ignore values <= 1 for prime detection.
Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Find Paths Across a Weighted Binary Grid - Amazon (medium)
  • Implement Multi-Player Tic-Tac-Toe - Amazon (medium)
  • Schedule Priority Jobs with Cooldowns - Amazon (medium)
  • Compute Edit Distance - Amazon (medium)
  • Minimize Replacements So Equal Product Values Are Contiguous - Amazon (hard)