Range Sum of BST | Leet code 938 | Theory explained + Python code

preview_player
Показать описание
This video is a solution to Leet code 938, Range Sum of BST. I explain the question, go over how the logic / theory behind solving the question and finally solve it using Python code.

Comment below if you have a better solution to this problem!

Let me know if you have any feedback and don't forget to subscribe for more videos!

Code:

Time stamps:
0:00 Question
1:50 Solution Explained
8:04 Python Code

More leetcode questions solved:
Рекомендации по теме
Комментарии
Автор

I like the way you explained. Good job!

vaishalisharma
Автор

Hey are you writing with mouse or another tablet+stylus?

cipherbenchmarks
Автор

Your coding skill is great.
Can you please let me know how to improve programming logic skills ?
Your you tube channel is great. All the best 👍

Shashank_Shahi
Автор

Great explanation!! I had a doubt, why are we calling inorder(root) in the end? Is it done to avoid the null nodes? Can you please help me.

anishkaagrawal
Автор

Thank you very much for this video.
I have done it in iterative way.
But I m traversing the complete tree. Could you please suggest how I can avoid complete traversal.
Follow is my solution.
def range_sum(self, node, low, high):
total=0
stack=[]
while node or stack:
while node:
stack.append(node)
node=node.left
node=stack.pop()
if node.data>=low and node.data<=high:
total+=node.data
node=node.right
return total

sharifmansuri
visit shbcf.ru