当前位置:网站首页>牛客-TOP101-BM34
牛客-TOP101-BM34
2022-07-21 00:57:00 【一条吃猫的鱼】
import java.util.*;
/* * public class TreeNode { * int val = 0; * TreeNode left = null; * TreeNode right = null; * public TreeNode(int val) { * this.val = val; * } * } */
public class Solution {
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param root TreeNode类 * @return bool布尔型 */
int pre = Integer.MIN_VALUE;
public boolean isValidBST (TreeNode root) {
// write code here
if(root == null)
return true;
if(!isValidBST(root.left))
return false;
if(root.val < pre)
return false;
//更新最值
pre = root.val;
//再进入右子树
return isValidBST(root.right);
}
}
边栏推荐
- Don't know how to learn MySQL? It's enough to finish the 50 questions of Niuke! (Part IX)
- 复盘:智能座舱系列文五- 它的3种交互方式之隐式交互
- Deep tide finance interprets usdd: look for a real stable currency through the illusion of decoupling
- 漏洞挖掘-ThinkPHP6.0.12LTS反序列化
- How to use sketch to design web pages and create grid guides tutorial
- 不知道 MySQL 咋学?刷完牛客这 50 道题就够了(第十篇)
- 2022-07-20: the following go language code is about JSON and context. What is the output? A:{}; B: {"a": "B"}; c:{"context": 0}; D: uncertain. Package main imp
- 【微信小程序】组件使用及属性参考
- 6 shell tips to make the script no longer amateur
- 2163. Minimum difference of sum after deleting elements [DP + heapq]
猜你喜欢
Web3.0 + Dao is the general trend, and safe creates a new world
The network cannot be found in the network icon in the lower right corner of the win10 desktop
FigDraw 16. SCI 文章绘图之树形图(Dendrogram)
网络安全学习(千锋网络安全笔记)3--批处理编写
Using zdog to realize JS special effect of outlook lighthouse animation
Vidéo d'utilisation à deux points 41 13.3. Détection des cibles et cadre de limitation AQ 13.4 cadre d'ancrage
Selenium web pages automatically acquire dynamic data
Explain cache penetration, cache avalanche, cache breakdown
狂神redis笔记05
Understand RTK Positioning, this one is enough!
随机推荐
NFS FTP PXE
不知道 MySQL 咋学?刷完牛客这 50 道题就够了(第十篇)
Knowledge atlas enables digital economy. The 16th National knowledge atlas and Semantic Computing Conference (CCKS 2022) is about to be held
H5 mobile game run rabbit source code download
Mongodb tutorial Chapter 07 crud search document
Dynamic memory management
NPM settings download source
Network Security Learning (Qianfeng network security notes) 3 -- batch preparation
不知道 MySQL 咋学?刷完牛客这 50 道题就够了!(第七篇)
map遍历
Video 4413.8 regional convolutional neural network (r-cnn) series 13.5 multiscale target detection & 13.6 target detection data set
MFC计算器
七. 实战——常用工具类的一些方法
aijs 添加虚线
登录和注册页面扁平化设计
六.实战——Excel表格的导入和导出
WEB3.0+DAO大势所趋,SAFE开创新世界
Compatibility problems of installing MySQL in centos7
冒號用法 視頻41 13.3. 目標檢測和邊界框 QA 13.4錨框
[test development] software testing - Test Case Design & detailed explanation of test classification