Same idea. Slow too. Have fun with it. lol

class Solution {
public boolean verifyPreorder(int[] preorder) {
return helper(preorder, 0, preorder.length - 1);
}
public boolean helper(int[] preorder, int start, int end) {
if (start >= end) {
return true;
}
int root = preorder[start];
int i = start + 1;
while (i <= end){
if (preorder[i] > root) {
break;
}
i++;
}
if (!valid(preorder, root, i, end)) {
return false;
}
return helper(preorder, start + 1, i - 1) && helper(preorder, i, end);
}
public boolean valid(int[] preorder, int root, int start, int end) {
if (start > end) {
return true;
}
for (int i = start; i <= end; i++) {
if (preorder[i] < root) {
return false;
}
}
return true;
}
}