Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0cc223a

Browse files
refactor 108
1 parent84152b2 commit0cc223a

File tree

1 file changed

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

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ public TreeNode sortedArrayToBST(int[] num) {
99
returndfs(num,0,num.length -1);
1010
}
1111

12-
publicTreeNodedfs(int[]num,intstart,intend) {
13-
if (start >end) {
12+
publicTreeNodedfs(int[]num,intleft,intright) {
13+
if (left >right) {
1414
returnnull;
1515
}
16-
intmid =(end +start) /2;
17-
TreeNoderoot =newTreeNode(num[mid]);
18-
root.left =dfs(num,start,mid -1);
19-
root.right =dfs(num,mid +1,end);
20-
returnroot;
16+
intmid =left +(right -left) /2;
17+
TreeNodenode =newTreeNode(num[mid]);
18+
node.left =dfs(num,left,mid -1);
19+
node.right =dfs(num,mid +1,right);
20+
returnnode;
2121
}
2222
}
2323
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp