PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Amazon

Compute array modes with ties and no-mode rule

Last updated: Mar 29, 2026

Quick Overview

This question evaluates algorithm design and data-structure skills—frequency counting, hashing, and handling edge cases such as ties and a no-mode rule—within the coding and algorithms domain for data scientist roles.

  • Medium
  • Amazon
  • Coding & Algorithms
  • Data Scientist

Compute array modes with ties and no-mode rule

Company: Amazon

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

Write a function that returns the mode(s) of an integer array. Requirements: if all values are unique, return an empty list (there is no mode); allow and return multiple modes, ordered by first occurrence in the input; run in O(n) expected time and O(u) extra space where u is the number of unique values. Follow-ups: 1) How would you support a streaming array with unknown length using O(u_window) space and emit current modes over a sliding window of size W? 2) How would you break ties deterministically in case-insensitive string data while preserving stable order? 3) Analyze worst-case time and space. Examples: [3,1,2,2,3] -> [3,2] (both appear twice); [1,2,3] -> []; [7,7,7] -> [7].

Quick Answer: This question evaluates algorithm design and data-structure skills—frequency counting, hashing, and handling edge cases such as ties and a no-mode rule—within the coding and algorithms domain for data scientist roles.

Related Interview Questions

  • Implement Datacenter Router Commands - Amazon (hard)
  • Replace Delimited Tokens in a String - Amazon (medium)
  • Minimize Circular Redistribution Cost - Amazon (medium)
  • Find the Most Common Visit Pattern - Amazon (hard)
  • Maximize Value Under a Budget - Amazon (medium)
Amazon logo
Amazon
Oct 13, 2025, 9:49 PM
Data Scientist
Technical Screen
Coding & Algorithms
2
0

Write a function that returns the mode(s) of an integer array. Requirements: if all values are unique, return an empty list (there is no mode); allow and return multiple modes, ordered by first occurrence in the input; run in O(n) expected time and O(u) extra space where u is the number of unique values. Follow-ups: 1) How would you support a streaming array with unknown length using O(u_window) space and emit current modes over a sliding window of size W? 2) How would you break ties deterministically in case-insensitive string data while preserving stable order? 3) Analyze worst-case time and space. Examples: [3,1,2,2,3] -> [3,2] (both appear twice); [1,2,3] -> []; [7,7,7] -> [7].

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Amazon•More Data Scientist•Amazon Data Scientist•Amazon Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

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

Product

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

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL 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.