FastPrepBinary Min-Heap Operations
Problems/Binary Min-Heap Operations

Binary Min-Heap Operations

Citadel logoCitadel● MediumINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Citadel intern phone screen. The report names a heap-implementation question in the first technical interview. It leaves out whether the heap is min or max, the exact operations, duplicates, empty results, the limits, and the examples. Our version is a batch of operations on a binary min-heap. It is about 80% the same as the reported question.

Implement a min-heap and process operations on an initially empty collection:

  • [0,value]: insert one copy of value.
  • [1,0]: return the smallest stored value without removing it, or -1 if empty.
  • [2,0]: remove and return one copy of the smallest stored value, or -1 if empty.

Return the results of type-1 and type-2 operations in operation order. Duplicate values are independent copies. Implement the heap structure yourself rather than using a library priority queue.

Function

minHeapOperations(operations: int[][]) → int[]

Examples

Example 1

operations = [[0,5],[0,2],[0,7],[1,0],[2,0],[1,0],[2,0],[2,0],[2,0]]return = [2,2,5,5,7,-1]

The three inserted values are 5, 2, and 7. Peeking returns 2 and leaves it in the heap. The removals then return 2, 5, and 7, with a peek of 5 between the first two removals. The last removal returns -1 because the heap is empty.

Example 2

operations = [[0,3],[0,3],[2,0],[1,0],[2,0],[1,0]]return = [3,3,3,-1]

Removing one copy of 3 leaves the other copy available. After both copies are removed, the final peek returns -1.

Constraints

  • 0 <= operations.length <= 100000.
  • Every operation contains exactly two integers.
  • The operation code is 0, 1, or 2.
  • 0 <= value <= 10^9.
  • Peek and removal operations have a second value of zero.

More Citadel Phone Screen questions

  • Portfolio Tickers with Constant-Time Random PickPHONE SCREEN · Seen Nov 2026
  • Square Root FunctionPHONE SCREEN · Seen Oct 2026
  • Reachable Transfer PositionsPHONE SCREEN · Seen Oct 2026
  • Spreadsheet Formula DependenciesPHONE SCREEN · Seen Oct 2026
  • Merge Price-Delta FeedsPHONE SCREEN · Seen Sep 2026
  • Reconcile Unmatched Trades with Timestamp TolerancePHONE SCREEN · Seen Sep 2026
  • Top Ten Trades by Notional ValuePHONE SCREEN · Seen Sep 2026
  • Exchange BBO and Market-Wide NBBOPHONE SCREEN · Seen Sep 2026
  • Maximize Workday EarningsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Minimum Changes for Palindromic BlocksOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Running Medians and PercentilesStackAdapt · PHONE SCREENStackAdapt interview questions
  • Top K Largest Values from a StreamThe D.E. Shaw Group · ONSITE INTERVIEWThe D.E. Shaw Group interview questions
  • Fixed-K Kth Largest StreamAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
  • Fixed-K Kth Largest StreamGoogle · ONSITE INTERVIEWGoogle interview questions
  • Top K With a Deterministically Noisy Comparator (MLE)Mercor · ONSITE INTERVIEWMercor interview questions
  • Customer Bootstrap APIDoorDash · PHONE SCREEN · ONSITE INTERVIEWDoorDash interview questions
  • Design Hit CounterCharta Health · PHONE SCREENCharta Health interview questions
  • Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
  • Task Scheduler with Prerequisites and Execution PathsBrex · PHONE SCREEN
  • Streaming Median of Trade PricesXantium · PHONE SCREEN

Interview reports that mention this question

  • Citadel Securities SWE Intern First Round: 2 Experiences

Citadel interview experiences

  • Citadel Securities Quant Researcher Intern Loop: 1 Experience
  • Citadel Securities Research Engineer Interview: 1 Experience
  • Citadel Securities Experienced SWE Interviews: 1 Experience
  • Citadel SWE Intern Later Rounds and Superday: 13 Experiences
  • Citadel SWE Intern First-Round Questions: 20 Experiences
All Citadel interview questionsSee Citadel hiring insights
Saved
class Solution {
    public int[] minHeapOperations(int[][] operations) {
        // Write your code here.
    }
}
Checking account…