diff options
Diffstat (limited to 'balance_bst.c')
-rw-r--r-- | balance_bst.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/balance_bst.c b/balance_bst.c new file mode 100644 index 0000000..e6cdb28 --- /dev/null +++ b/balance_bst.c @@ -0,0 +1,17 @@ +// 1382. Balance a Binary Search Tree +#include "leetcode.h" + +/* + * given the 'root' of a binary search tree, return a balanced binary search + * tree with the same node values. if there is more than one answer, return any + * of them. a binary search tree is balanced if the depth of the two subtrees of + * every node never differs by more than 1. + */ + +struct TreeNode { + int val; + struct TreeNode *left; + struct TreeNode *right; +}; + +struct TreeNode *balanceBST(struct TreeNode *root) {} |