FastPrepValidate a Strict Binary Search Tree
Problems/Validate a Strict Binary Search Tree

Validate a Strict Binary Search Tree

Amazon logoAmazon● MediumINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The Applied Scientist intern screen asks whether a binary tree is a BST. The report omits duplicate policy, empty-tree behavior and bounds; this exercise supplies the conventional strict BST contract. Approximate source match: 90%.

You are given the root of a binary tree. Return true if it is a binary search tree, and false if it is not.

Use the strict rule. Every value in a node's whole left subtree must be smaller than the node's value. Every value in its whole right subtree must be larger. Equal values are not allowed. An empty tree counts as valid.

Function

isStrictBST(root: TreeNode) → boolean

Examples

Example 1

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

The left child is smaller than the root, and the right child is larger. So the tree is valid, and the answer is true.

Example 2

root = [5,1,4,null,null,3,6]return = false
root
51436

The right subtree holds 4 and 3. Every value there must be larger than the root 5, but these two are smaller. So the tree is not valid, and the answer is false.

Example 3

root = []return = true
root
empty

The tree is empty, and an empty tree counts as valid. The answer is true.

Constraints

  • The tree has 0 to 500 nodes.
  • -10^9 <= node.val <= 10^9.

More Amazon Phone Screen questions

  • Count Connected ComponentsPHONE SCREEN · Seen Dec 2026
  • LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Merge Accounts by Shared AttributePHONE SCREEN · Seen Dec 2026
  • Merge IntervalsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Task SchedulerOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Merge k Sorted ListsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Search in a Rotated Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent ElementsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Course Schedule IIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • N-ary Index-Path Encoder and DecoderBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • House Robber IIIOkta · PHONE SCREENOkta interview questions
  • Render a Task Tree from CSV RowsStripe · PHONE SCREEN · ONSITE INTERVIEWStripe interview questions
  • Validate Binary Search TreeKotak Mahindra Bank · PHONE SCREENKotak Mahindra Bank interview questions
  • House Robber IIIGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • Binary Tree Target-Sum PathsByteDance · PHONE SCREENByteDance interview questions
  • House Robber IIIVisa · PHONE SCREENVisa interview questions
  • Find All Paths for a Name in a File SystemThe Walt Disney Company · PHONE SCREENThe Walt Disney Company interview questions
  • Validate a BST with a Custom ComparisonApple · PHONE SCREENApple interview questions
  • Filter Undesired Comments and Their DescendantsReddit · PHONE SCREEN · ONSITE INTERVIEWReddit interview questions

Interview reports that mention this question

  • Amazon SDE II Onsite and L5 Screens: 7 Experiences (Part 2 of 2)
  • Amazon SDE II OA and Interviews: 10 Experiences (Part 1 of 2)

Amazon interview experiences

  • Amazon Experienced SDE Onsite Questions: 1 Experience
  • Amazon SDE Onsite Interview Questions: 9 Experiences
  • Amazon SDE II and L5 FDE Interview Questions: 4 Experiences
  • Amazon Full-Time OA Problems, Earlier Reports (Part 5 of 5)
See Amazon 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 isStrictBST(TreeNode root) {
        // Write your code here
    }
}
Checking account…