Step 1 of 4

Root Inspection & Array Representation

Start by understanding how the tree maps to array indices and implement peek().

  • peek(): Returns the minimum value (the root at index 0) without removing it. If the heap is empty, return null / None.
  • size(): Returns the number of elements in the heap.

Your build

Running is free — Submit is what records the step. Or press ⌘↩

Tests

1 case
calltypeexpectedresult
runOps([["peek"],["size"],["push",42],["peek"],["size"]])peeks empty and non-empty heap[null,0,null,42,1]

Hints

Stuck? Hints open one at a time, each giving a little more away.

2 hints left