PracHub
QuestionsLearningGuidesInterview Prep

Quick Overview

Practice a Google coding interview problem focused on return the most frequent values in an array. The prompt emphasizes edge cases, clean implementation, and verifiable test behavior without revealing the solution.

  • medium
  • Google
  • Coding & Algorithms
  • Software Engineer

Return the Most Frequent Values in an Array

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Given a non-empty integer array, return the `k` values that appear most frequently. Ties are broken by smaller value first. Implement: ```python def top_k_frequent(nums: list[int], k: int) -> list[int]: pass ```

Quick Answer: Practice a Google coding interview problem focused on return the most frequent values in an array. The prompt emphasizes edge cases, clean implementation, and verifiable test behavior without revealing the solution.

Return k values with highest frequency, breaking ties by smaller value.

Examples

Input: {"nums":[1,1,1,2,2,3],"k":2}

Expected Output: [1,2]

Explanation: Common sample.

Input: {"nums":[1],"k":1}

Expected Output: [1]

Explanation: Single.

Last updated: Jul 4, 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

  • Count Overlapping Rectangle Updates on a Grid - Google (hard)
  • Find A Threshold-Limited Path With Minimum Required Safety - Google (medium)
  • Filter Repeated Robot Status Messages - Google (medium)
  • Minimize Direction Violations in a Directed Road Network - Google (medium)
  • Find the Largest Monotone Increasing Number - Google (medium)