当前位置:网站首页>LeetCode 938.二叉搜索树的范围和(简单)
LeetCode 938.二叉搜索树的范围和(简单)
2022-08-10 05:32:00 【生信研究猿】
pyhton 前序遍历
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def rangeSumBST(self, root: Optional[TreeNode], low: int, high: int) -> int:
self.count = 0
if root==None:
return None
self.inorder(root,low,high)
return self.count
def inorder(self,root,low,high):
p = root
if p==None:
return
if(p.val>=low and p.val<=high):
self.count +=p.val
self.inorder(p.left,low,high)
self.inorder(p.right,low,high)
边栏推荐
- Set Sources Resources and other folders in the IDEA project
- WeChat applet wx.writeBLECharacteristicValue Chinese character to buffer problem
- The latest and most complete digital collection sales calendar-07.26
- 【笔记】集合框架体系 Collection
- Count down the six weapons of the domestic interface collaboration platform!
- Chained Picks: Starbucks looks at digital collectibles and better engages customers
- 链读好文:Jeff Garzik 推出 Web3 制作公司
- 第十天作业
- sqlplus 显示上一条命令及可用退格键
- 力扣——情侣牵手
猜你喜欢
21天挑战杯MySQL-Day05
Set Sources Resources and other folders in the IDEA project
十年磨一剑!数字藏品行情软件,链读APP正式开放内测!
tinymce rich text editor
链读|最新最全的数字藏品发售日历-08.02
【笔记】集合框架体系 Collection
Chained Picks: Starbucks looks at digital collectibles and better engages customers
The latest and most complete digital collection sales calendar-07.26
程序员副业赚钱之道,实现月收入增加20K
最新最全的数字藏品发售日历-07.27
随机推荐
LeetCode 面试题17.14 最小k个数(中等)
network security firewall
图片批量添加水印批量缩放图片到指定大小
第六次实验
ORACLE系统表空间SYSTEM占满无法扩充表空间问题解决过程
一个基于.Net Core 开源的物联网基础平台
[Difference between el and template]
网络安全之防火墙
String常用方法
链读推荐:从瓷砖到生成式 NFT
Chain Reading Recommendation: From Tiles to Generative NFTs
el-dropdown drop-down menu style modification, remove the small triangle
程序员副业赚钱之道,实现月收入增加20K
Knowledge Distillation Thesis Learning
力扣——情侣牵手
GUI_AWT
探索性数据分析EDA
视图【】【】【】【】
最新最全的数字藏品发售日历-07.26
Chain Reading | The latest and most complete digital collection calendar-07.28