public TreeNode sortedListToBST(ListNode head) {
        if(head == null) return null;
        if(head.next == null) return new TreeNode(head.val);
        ListNode preMid = getPreMid(head);
        ListNode mid = preMid.next;
        preMid.next = null;
        ListNode first = head, second = mid.next;
        TreeNode root = new TreeNode(mid.val);
        root.left = sortedListToBST(first);
        root.right = sortedListToBST(second);
        return root;
    }