Skip to content

Commit 04c577b

Browse files
refactor 108
1 parent dbb903f commit 04c577b

File tree

1 file changed

+6
-6
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+6
-6
lines changed

src/main/java/com/fishercoder/solutions/_108.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ public class _108 {
2323

2424
public static class Solution1 {
2525
public TreeNode sortedArrayToBST(int[] num) {
26-
return rec(num, 0, num.length - 1);
26+
return dfs(num, 0, num.length - 1);
2727
}
2828

29-
public TreeNode rec(int[] num, int low, int high) {
30-
if (low > high) {
29+
public TreeNode dfs(int[] num, int start, int end) {
30+
if (start > end) {
3131
return null;
3232
}
33-
int mid = low + (high - low) / 2;
33+
int mid = start + (end - start) / 2;
3434
TreeNode root = new TreeNode(num[mid]);
35-
root.left = rec(num, low, mid - 1);
36-
root.right = rec(num, mid + 1, high);
35+
root.left = dfs(num, start, mid - 1);
36+
root.right = dfs(num, mid + 1, end);
3737
return root;
3838
}
3939
}

0 commit comments

Comments
 (0)