Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Validate BST
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; class TreeNode { int val; TreeNode left; TreeNode right; TreeNode(int x) { val = x; } } class Rextester { public static void main(String args[]) { System.out.println(Double.MIN_VALUE); } public boolean isValidBST(TreeNode root) { Stack<TreeNode> stack = new Stack<>(); int minVal = Integer.MIN_VALUE; while(root!=null || !stack.isEmpty()){ while(root!=null){ stack.push(root); root = root.left; } root = stack.pop(); if(root.val<minVal) return false; minVal = root.val; root = root.right; } return true; } }
run
|
edit
|
history
|
help
0
updated
A.K.JAVA_EXPERIENCE_2
Word pattern
Armstrong Number in Java
practicecode
1.5
Display Page (Pagination)
inheritance
Counter.java
Municipiu_Problema_2_Palindrome