@@ -0,0 +1,784 @@
+public class LeetCode0109 %7B%0A%0A%09class ListNode %7B%0A%09%09int val;%0A%09%09ListNode next;%0A%0A%09%09ListNode(int x) %7B%0A%09%09%09val = x;%0A%09%09%7D%0A%09%7D%0A%0A%09class TreeNode %7B%0A%09%09int val;%0A%09%09TreeNode left;%0A%09%09TreeNode right;%0A%0A%09%09TreeNode(int x) %7B%0A%09%09%09val = x;%0A%09%09%7D%0A%09%7D%0A%0A%09private ListNode current;%0A%0A%09public TreeNode sortedListToBST(ListNode head) %7B%0A%09%09if (head == null) %7B%0A%09%09%09return null;%0A%09%09%7D%0A%09%09int size = 0;%0A%09%09current = head;%0A%09%09for (ListNode p = head; p != null; p = p.next) %7B%0A%09%09%09size++;%0A%09%09%7D%0A%0A%09%09return dfs(head, size);%0A%09%7D%0A%0A%09private TreeNode dfs(ListNode head, int size) %7B%0A%0A%09%09if (size == 0) %7B%0A%09%09%09return null;%0A%09%09%7D%0A%0A%09%09TreeNode left = dfs(head, size / 2);%0A%09%09TreeNode root = new TreeNode(current.val);%0A%09%09current = current.next;%0A%09%09TreeNode right = dfs(head, size - size / 2 - 1);%0A%09%09root.left = left;%0A%09%09root.right = right;%0A%09%09return root;%0A%09%7D%0A%7D

Add LeetCode0109.java