Convert Sorted Array to BST | Leetcode - 108 | Trees #14

preview_player
Показать описание
#14 Trees | Convert Sorted Array to BST | Leetcode - 108 |Beginner-Friendly Course | Data Structure

Given an array where elements are sorted in ascending order, convert it to a height balanced BST.

For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1.

Example:

Given the sorted array: [-10,-3,0,5,9],

One possible answer is: [0,-3,9,-10,null,5], which represents the following height balanced BST:

0
/ \
-3 9
/ /
-10 5

Code Link :

Check out our other popular playlists:

If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful.

#coding #dataStructure #programminglife #programmingisfun #programmer #tech #software #codinglife #leetcode
Рекомендации по теме
Комментарии
Автор

We hope you all are enjoying our videos!!! Don't forget to leave a comment!!! Please like the video to support us!!!

Questions you might like:

Struggling in a question??

Leave in a comment and we will make a video!!!🙂🙂🙂

AlgorithmsMadeEasy
Автор

The best explanation on the problem, from basic to expert. Many Thanks

abhijitbiradar
Автор

In some way your explanation is even clearer than Neetcode video of the same LC 108 problem.

CostaKazistov
Автор

Thanks for taking this question!!
Good explanation!
It helped me.

gawarivivek
Автор

if the arraay size is not odd then what

Habibyt_
Автор

ok but can anyone explain how does this approach guarantee that we will get a height balanced binary search tree?

xacademia
Автор

can you tell me TreeNode is variable or function

Eshankhan
Автор

You explained very well. But there is a suggestion for you:- Teach in PYTHON...C is in past now
.
.
.
Otherwise your channel won't grow anymore.😊

aniketdutta