public boolean dfs(TreeNode root, long min, long max) {
        if (root == null)
            return true;
        int val = root.val;
        if (val < max && val > min && dfs(root.left, min, root.val) && dfs(root.right, root.val, max))
            return true;
        return false;
    }