java.lang.Object
g0601_0700.s0700_search_in_a_binary_search_tree.Solution

public class Solution extends Object
700 - Search in a Binary Search Tree.<p>Easy</p> <p>You are given the <code>root</code> of a binary search tree (BST) and an integer <code>val</code>.</p> <p>Find the node in the BST that the node&rsquo;s value equals <code>val</code> and return the subtree rooted with that node. If such a node does not exist, return <code>null</code>.</p> <p><strong>Example 1:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2021/01/12/tree1.jpg" alt="" /></p> <p><strong>Input:</strong> root = [4,2,7,1,3], val = 2</p> <p><strong>Output:</strong> [2,1,3]</p> <p><strong>Example 2:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2021/01/12/tree2.jpg" alt="" /></p> <p><strong>Input:</strong> root = [4,2,7,1,3], val = 5</p> <p><strong>Output:</strong> []</p> <p><strong>Constraints:</strong></p> <ul> <li>The number of nodes in the tree is in the range <code>[1, 5000]</code>.</li> <li><code>1 <= Node.val <= 10<sup>7</sup></code></li> <li><code>root</code> is a binary search tree.</li> <li><code>1 <= val <= 10<sup>7</sup></code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details