当前位置:网站首页>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)

边栏推荐
- 【List练习】遍历集合并且按照价格从低到高排序,
- Linux数据库Oracle客户端安装,用于shell脚本用sqlplus连接数据库
- [Notes] Collection Framework System Collection
- Content related to ZigBee network devices
- sqlplus displays the previous command and the available backspace key
- 21天挑战杯MySQL-Day05
- Bifrost micro synchronous database implementation services across the library data synchronization
- Using sqlplus to operate database in shell script
- 图片批量添加水印批量加背景缩放批量合并工具picUnionV4.0
- opencv
猜你喜欢

view【】【】【】【】

链读|最新最全的数字藏品发售日历-07.29

一个基于.Net Core 开源的物联网基础平台

定时器(setInterval)的开启与关闭

Chain Reading | The latest and most complete digital collection calendar-07.28

先人一步,不再错过,链读APP即将上线!

链读推荐:从瓷砖到生成式 NFT

.NET操作Excel高效低内存的开源框架 - MiniExcel

Reflection 【Notes】

Link reading good article: What is the difference between hot encrypted storage and cold encrypted storage?
随机推荐
impdp 导入数据
力扣——省份数量
network security firewall
.Net Core导入千万级数据至Mysql
Chain Reading|The latest and most complete digital collection sales calendar-07.29
各个架构指令集对应的机型
Collection Map
图片批量添加水印批量缩放图片到指定大小
Content related to ZigBee network devices
view【】【】【】【】
generic notes()()()
私有化搭建个人网盘 NextCloud
去中心化和p2p网络以及中心化为核心的传统通信
链表API设计
连接 Nacos 报超时错误
集合 set接口
cesium listens to map zoom or zoom to control whether the content added on the map is displayed
LeetCode 94.二叉树的中序遍历(简单)
菜谱小程序源码免费分享【推荐】
Chain Reading Recommendation: From Tiles to Generative NFTs