From 1804364c01b53a986c369e874c332f355b286ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C5=9F=C4=B1nsu=20Ar=C4=B1c=C4=B1?= Date: Fri, 7 Jan 2022 23:58:52 +0300 Subject: [PATCH] 938 --- E_938_RangeSumofBST.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 E_938_RangeSumofBST.java diff --git a/E_938_RangeSumofBST.java b/E_938_RangeSumofBST.java new file mode 100644 index 0000000..7a47bd3 --- /dev/null +++ b/E_938_RangeSumofBST.java @@ -0,0 +1,10 @@ +class Solution { + public int rangeSumBST(TreeNode root, int low, int high) { + if(root==null) return 0; + if(root.val> high) + return rangeSumBST(root.left, low, high); + if(root.val< low) + return rangeSumBST(root.right, low, high); + return root.val+rangeSumBST(root.left,low,high)+rangeSumBST(root.right, low, high); + } +} \ No newline at end of file