FastPrepValidate Binary Search Tree
Problems/Validate Binary Search Tree

Validate Binary Search Tree

SambaNova Systems logoSambaNova Systems● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A firsthand SambaNova five-round onsite report dated June 30, 2022 clearly describes the well-known Validate Binary Search Tree problem.

Return whether the binary tree is a valid binary search tree. Every value in a left subtree must be strictly smaller than its ancestor, and every value in a right subtree must be strictly larger.

Function

isValidBST(root: TreeNode) → boolean

Examples

Example 1

root = [2,1,3]return = true
root
213

Both children satisfy the strict bounds imposed by the root.

Constraints

  • The tree contains between 1 and 10000 nodes.
  • Node values fit in a signed 32-bit integer.

More SambaNova Systems Onsite Interview questions

  • Vectorized K-Means AssignmentsONSITE INTERVIEW · Seen Apr 2024
  • 4Sum II Tuple CountONSITE INTERVIEW · Seen Jun 2022
  • Bomb Enemy Best CoordinatesONSITE INTERVIEW · Seen Jun 2022
  • Sum Nodes with an Even-Valued GrandparentONSITE INTERVIEW · Seen Jun 2022
  • Deterministic Zigzag SortPHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2022
  • Maximum Area of IslandONSITE INTERVIEW · Seen Jun 2022
  • Task Scheduler with CooldownPHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2022
  • Point Inside a TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2022
  • Parse Variable, Expression, and Application TreesPHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2022
  • Flip Equivalent Binary TreesONSITE INTERVIEW · Seen Oct 2021

Similar questions at other companies

  • Diagonal Traversal of a Binary TreeAmazon · ONSITE INTERVIEW
  • Render an Org Chart and Find Skip-Level PairsSnap Inc. · ONSITE INTERVIEWSnap Inc. interview questions
  • Find Leaves of a Binary TreeLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • N-ary Index-Path Encoder and DecoderBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Delete Nodes and Return Forest RootsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Render a Task Tree from CSV RowsStripe · PHONE SCREEN · ONSITE INTERVIEWStripe interview questions
  • Filter Undesired Comments and Their DescendantsReddit · PHONE SCREEN · ONSITE INTERVIEWReddit interview questions
  • JSON Path Lookup with Implicit Array WildcardsMongoDB · ONSITE INTERVIEWMongoDB interview questions
  • Delete and Compact a Forest SubtreePinterest · PHONE SCREEN · ONSITE INTERVIEWPinterest interview questions
  • Onion-Peel Layers of a Binary TreeeBay · ONSITE INTERVIEWeBay interview questions
All SambaNova Systems interview questionsSee SambaNova Systems 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 boolean isValidBST(TreeNode root) {
      // Write your code here.
    }

}
Checking account…