FastPrepEquity Price History with O(1) Statistics
Problems/Equity Price History with O(1) Statistics

Equity Price History with O(1) Statistics

Bloomberg LP logoBloomberg LP● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Bloomberg new grad onsite interview. The report keeps append or update, remove latest, latest, maximum, and average, all in O(1), plus a talk about object-oriented design. It leaves out how operations come in a batch and how the numbers are written out. Here prices are whole cents and averages are reduced fractions. Our version is about 92% the same as the reported question.

Process a finite sequence of operations over one equity's daily price history. Prices are nonnegative integer cents.

  • ["UPDATE", price] appends the next daily price.
  • ["REMOVE"] removes the most recently appended price.
  • ["LATEST"] emits the latest price as an integer string.
  • ["MAX"] emits the maximum current price as an integer string.
  • ["AVERAGE"] emits the exact current average as a reduced numerator/denominator string. Always include the denominator, even when it is 1.

Every remove or query is valid: at least one price exists before that operation. Return query results in encounter order. Design the history so every operation runs in O(1) time.

Function

processEquityPrices(operations: String[][]) → String[]

Examples

Example 1

operations = [["UPDATE","100"],["UPDATE","120"],["AVERAGE"],["MAX"],["LATEST"],["REMOVE"],["AVERAGE"],["LATEST"]]return = ["110/1","120","120","100/1","100"]

After two updates the average is 220/2 = 110/1. Removing the latest price restores the one-price history.

Example 2

operations = [["UPDATE","0"],["UPDATE","1"],["UPDATE","2"],["AVERAGE"],["REMOVE"],["AVERAGE"],["MAX"],["LATEST"]]return = ["1/1","1/2","1","1"]

The first average is 3/3, reduced to 1/1. After removing 2, the exact average is 1/2.

Example 3

operations = [["UPDATE","5"],["UPDATE","3"],["UPDATE","8"],["REMOVE"],["MAX"],["LATEST"],["AVERAGE"]]return = ["5","3","4/1"]

Removing 8 exposes 3 as the latest price while the remaining maximum is 5.

Constraints

  • 1 <= operations.length <= 100000.
  • Each operation is one of the five documented forms.
  • 0 <= price <= 1000000000.
  • REMOVE, LATEST, MAX, and AVERAGE occur only when the history is nonempty.
  • The sum of current prices fits in a signed 64-bit integer.

More Bloomberg LP Onsite Interview questions

  • Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • 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

Similar questions at other companies

  • KV Store with Nested TransactionsApplied Intuition · PHONE SCREEN · ONSITE INTERVIEWApplied Intuition interview questions
  • Min StackDP World · ONSITE INTERVIEW
  • Calculate a Token-List ExpressionCollege Vine · ONSITE INTERVIEW
  • Code Editor FoldingJane Street · ONSITE INTERVIEWJane Street interview questions
  • Real-Time Temperature Window StatisticsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Subtract Forward-Order Linked-List NumbersMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Undo and Redo Command HistoryNetflix · ONSITE INTERVIEWNetflix interview questions
  • Text Embedding and Vector SearchNike, Inc. · PHONE SCREEN · ONSITE INTERVIEWNike, Inc. interview questions
  • Stock System with Updates and Percentage ChangeLead Bank · ONSITE INTERVIEWLead Bank interview questions
  • Text Document HistoryNotion · PHONE SCREEN · ONSITE INTERVIEWNotion interview questions

Interview reports that mention this question

  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
  • Bloomberg New Grad SWE Offer Loops: 14 Experiences (Part 2 of 5)
  • Bloomberg New Grad SWE Interviews: 98 Experiences (Part 1 of 5)

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
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public String[] processEquityPrices(String[][] operations) {
        // Write your code here.
    }

}
Checking account…