Range Sum of BST 🍐

Input: root = [10,5,15,3,7,null,18], low = 7, high = 15
Output: 32
Explanation: Nodes 7, 10, and 15 are in the range [7, 15]. 7 + 10 + 15 = 32.
Input: root = [10,5,15,3,7,13,18,1,null,6], low = 6, high = 10
Output: 23
Explanation: Nodes 6, 7, and 10 are in the range [6, 10]. 6 + 7 + 10 = 23.
  • The number of nodes in the tree is in the range [1, 2 * 104].
  • 1 <= Node.val <= 105
  • 1 <= low <= high <= 105
  • All Node.val are unique.

Solution

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Mastering Apache Kafka on Kubernetes — Strimzi K8s operator

TTY Toolkit- A CLI App’s Best Friend

Concurrency is not Parallelism — A deeper look at their difference

What are the credentials you should check before hiring a Software Development Company

Clone Graph 🛴

Things to Note for the Leaders of Remote Technology Teams in the COVID-19 Landscape

6 VSCode Features/Extensions/Things You Need To Start Using

[Our Mission] — The Duty of the Developer As A Professional #1

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tehleel Mir 🐢

Tehleel Mir 🐢

More from Medium

Lowest Common Ancestor of a Binary Search Tree 🐳

Split Function

DS practice

Strings: Palindrome