当前位置:网站首页>LeetCode 938. Range Sum of Binary Search Trees (Simple)
LeetCode 938. Range Sum of Binary Search Trees (Simple)
2022-08-10 05:55:00 【Shengxin Research Ape】
pyhton preorder traversal
# 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 = rightclass Solution:def rangeSumBST(self, root: Optional[TreeNode], low: int, high: int) -> int:self.count = 0if root==None:return Noneself.inorder(root,low,high)return self.countdef inorder(self,root,low,high):p = rootif p==None:returnif(p.val>=low and p.val<=high):self.count +=p.valself.inorder(p.left,low,high)self.inorder(p.right,low,high)
边栏推荐
猜你喜欢

Set Sources Resources and other folders in the IDEA project

Common class String overview

Collection工具类

ORACLE system table space SYSTEM is full and cannot expand table space problem solving process

操作表 函数的使用

【笔记】集合框架体系 Collection

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

LeetCode 剑指offer 21.调整数组顺序使奇数位于偶数前面(简单)

测一测异性的你长什么样?

LeetCode 938.二叉搜索树的范围和(简单)
随机推荐
Batch add watermark to pictures batch scale pictures to specified size
先人一步,不再错过,链读APP即将上线!
Linux database Oracle client installation, used for shell scripts to connect to the database with sqlplus
并查集原理与API设计
wiki confluence 安装
Set Sources Resources and other folders in the IDEA project
链读|最新最全的数字藏品发售日历-07.29
Chain Reading|The latest and most complete digital collection sales calendar-08.02
Timer (setInterval) on and off
opencv
Four characteristics of ACID
Index Notes【】【】
各个架构指令集对应的机型
impdp import data
IO流【】【】【】
generic notes()()()
ZigBee 网络设备相关内容
LeetCode 94.二叉树的中序遍历(简单)
[Notes] Collection Framework System Collection
十年磨一剑!数字藏品行情软件,链读APP正式开放内测!