```
public boolean verifyPreorder(int[] preorder) {
return verifyPreorder(preorder, 0, preorder.length-1);
}
private boolean verifyPreorder(int[] preorder, int l, int r) {
if(l >= r-1) return true;
int idx = l+1;
while(idx <= r) {
if(preorder[idx] > preorder[l])
break;
idx++;
}
for(int i=idx; i<=r; i++) {
if(preorder[i] < preorder[l]) return false;
}
return verifyPreorder(preorder, l+1, idx-1) && verifyPreorder(preorder, idx, r);
}
```

**The idea is to find the left subtree and the right subtree and then call this function on each of them. If this is a balanced BST, the time complexity will be O(nlogn).**