FastPrepBinary Search Tree Iterator
Problems/Binary Search Tree Iterator

Binary Search Tree Iterator

Atlassian logoAtlassian● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Atlassian full-time online assessment. The report links to the exact Binary Search Tree Iterator exercise but does not copy its full statement. Our version takes one finite list of operations, so the same state changes can be checked with a single function.

Process next and hasNext operations against one ascending BST iterator. next returns the next smallest value; hasNext reports whether another value remains. Return each result as a string in operation order.

Function

runBSTIterator(root: TreeNode, operations: String[]) → String[]

Examples

Example 1

root = [7,3,15,null,null,9,20]operations = ["next","next","hasNext","next","hasNext"]return = ["3","7","true","9","true"]
root
7315920

The iterator yields the inorder sequence and keeps its position between operations.

Constraints

  • The BST contains between 1 and 10000 unique nodes.
  • Every next operation is valid.
  • There are at most 20000 operations.

More Atlassian Online Assessment questions

  • Planning ProductionOA · Seen Feb 2025
  • K-Means ClusteringOA · Seen Feb 2025
  • Minimum Sorted Erasure OperationsOA · Seen Jun 2024
  • Count Analogous ArraysOA · Seen Mar 2024
  • Get Maximum ScoreOA · Seen Mar 2024
  • Better Compression 🦀OA · Seen Mar 2024
  • Romanizer 🐡OA · Seen Mar 2024
  • Flower Bouquets 💐OA · Seen Mar 2024
  • Binary Tree Level Order TraversalOA · Seen Nov 2023
  • Design HashMapOA · Seen Nov 2023

Similar questions at other companies

  • Lazy Binary Tree Inorder IteratorApple · PHONE SCREEN
  • Evaluate an Addition and Subtraction TreeExpedia · ONSITE INTERVIEW
  • Layer History with Batch Undo and RedoFigma · OA · PHONE SCREEN
  • Undo/Redo Timeline State EngineKickdrum · OA
  • Nested In-Memory Database TransactionsDRW · OA
  • Adding Stack 2.0IMC Trading · OA
  • Min StackShopify · OA
  • Text Editor OperationsMicrosoft · OA
  • Preorder, Inorder and Postorder of a Binary TreeCapital One · OA · ONSITE INTERVIEW
  • N-ary Index-Path Encoder and DecoderBloomberg LP · PHONE SCREEN · ONSITE INTERVIEW
See Atlassian hiring insights
Saved
/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode() {}
 *     TreeNode(int val) { this.val = val; }
 *     TreeNode(int val, TreeNode left, TreeNode right) {
 *         this.val = val;
 *         this.left = left;
 *         this.right = right;
 *     }
 * }
 */
class Solution {
    public String[] runBSTIterator(TreeNode root, String[] operations) {
      // Write your code here.
    }

}
Checking account…