Meta tags:
description= Given the root of a binary search tree (BST) and an integer target, split the tree into two subtrees where the first subtree has nodes that ...;
keywords= leetcode, javascript, solutions, algorithms, data structures, coding, programming, coding challenges, coding problems, coding solutions;
author= LeetCodeJavascript.com;
Headings (most frequently used words):
776, split, bst, problem, description, solution,
Text of the page (most frequently used words):
the (17), root (11), tree (9), target (9), left (6), right (6), val (5), return (5), smaller (5), binary (4), null (4), larger (4), split (4), node (3), treenode (3), this (3), undefined (3), splitbst (3), two (3), are (3), subtree (3), bst (3), that (3), all (3), value (3), leetcodejavascript (2), com (2), for (2), function (2), param (2), const (2), subtrees (2), original (2), should (2), with (2), parent (2), search (2), has (2), nodes (2), view (2), github (2), leetcode (2), 776 (2), solutions (2), 2025, josh, crozier, definition, number, var, else, solution, array, roots, order, additionally, most, structure, remain, formally, any, child, they, both, same, after, then, still, have, given, and, integer, into, where, first, equal, while, second, greater, than, not, necessarily, case, contains, problem, description, recursion, medium, back, star, javascript,
Text of the page (random words):
776 split bst leetcode javascript solutions leetcodejavascript com star on github back to all solutions 776 split bst medium view on leetcode view on github tree binary tree recursion binary search tree problem description given the root of a binary search tree bst and an integer target split the tree into two subtrees where the first subtree has nodes that are all smaller or equal to the target value while the second subtree has all nodes that are greater than the target value it is not necessarily the case that the tree contains a node with the value target additionally most of the structure of the original tree should remain formally for any child c with parent p in the original tree if they are both in the same subtree after the split then node c should still have the parent p return an array of the two roots of the two subtrees in order solution definition for a binary tree node function treenode val left right this val val undefined 0 val this left left undefined null left this right right undefined null right param treenode root param number target return treenode var splitbst function root target if root return null null if root val target const smaller larger splitbst root right target root right smaller return root larger else const smaller larger splitbst root left target root left larger return smaller root 2025 leetcodejavascript com josh crozier
|