FastPrepMaximum Frequency Stack
Problems/Maximum Frequency Stack

Maximum Frequency Stack

Bloomberg LP logoBloomberg LP● HardNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Bloomberg new-grad reports name this exact well-known problem. Our version is about 100% the same as the reported question.

Given operations and values, return the values removed by pop, in operation order.

Process the commands in operations using a frequency stack. A value's frequency is the number of times it is currently in the stack.

  • push adds the corresponding value from values.
  • pop removes and returns a value with the highest frequency. On a tie, remove the most recently pushed occurrence among those values.

Ignore the value paired with a pop.

Function

processFrequencyStack(operations: String[], values: int[]) → int[]

Examples

Example 1

operations = ["push","push","push","push","push","push","pop","pop","pop","pop"]values = [5,7,5,7,4,5,0,0,0,0]return = [5,7,5,4]

The first pop takes the only value with frequency 3. Each later pop takes a value with the highest frequency; on a tie, it takes the value whose remaining copy was pushed last.

Example 2

operations = ["push","push","pop","pop"]values = [1,2,0,0]return = [2,1]

Both values appear once, but 2 was pushed last, so it is popped first. The other value is then the only one left.

Example 3

operations = ["push","push","push","pop"]values = [9,9,3,0]return = [9]

The repeated value has a higher frequency than the value pushed last, so the only pop removes the repeated value.

Constraints

  • 1 <= operations.length == values.length <= 20000.
  • Each operation is push or pop.
  • 0 <= values[i] <= 10^9 for pushes.
  • Every pop occurs while the structure is nonempty.

More Bloomberg LP Onsite Interview questions

  • Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • KV Store with Nested TransactionsApplied Intuition · PHONE SCREEN · ONSITE INTERVIEWApplied Intuition interview questions
  • Nested Transaction Key-Value StorexAI · ONSITE INTERVIEWxAI interview questions
  • Transactional In-Memory RedisHashiCorp · ONSITE INTERVIEWHashiCorp interview questions
  • Key-Value Store with Nested TransactionsRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Maximum Frequency StackAmazon · PHONE SCREEN
  • Nested Recipe Cart TransactionsDecagon · PHONE SCREENDecagon interview questions
  • Maximum Frequency StackKalshi · PHONE SCREEN
  • Maximum Frequency StackInMobi · PHONE SCREENInMobi interview questions
  • Layer History with Batch Undo and RedoFigma · OA · PHONE SCREENFigma interview questions
  • In-Memory Database with Transactions and SavepointsNextdoor · PHONE SCREENNextdoor interview questions

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
  • Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public int[] processFrequencyStack(String[] operations, int[] values) {
        // Return values removed by pop operations.
    }
}
Checking account…