File tree Expand file tree Collapse file tree 1 file changed +14
-15
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 1 file changed +14
-15
lines changed Original file line number Diff line number Diff line change 9
9
*/
10
10
public class _108 {
11
11
12
- public static class Solution1 {
13
- public TreeNode sortedArrayToBST (int [] num ) {
14
- return rec (num , 0 , num .length - 1 );
15
- }
16
-
17
- public TreeNode rec (int [] num , int low , int high ) {
18
- if (low > high ) {
19
- return null ;
20
- }
21
- int mid = low + (high - low ) / 2 ;
22
- TreeNode root = new TreeNode (num [mid ]);
23
- root .left = rec (num , low , mid - 1 );
24
- root .right = rec (num , mid + 1 , high );
25
- return root ;
26
- }
12
+ public static class Solution1 {
13
+ public TreeNode sortedArrayToBST (int [] num ) {
14
+ return rec (num , 0 , num .length - 1 );
27
15
}
28
16
17
+ public TreeNode rec (int [] num , int low , int high ) {
18
+ if (low > high ) {
19
+ return null ;
20
+ }
21
+ int mid = low + (high - low ) / 2 ;
22
+ TreeNode root = new TreeNode (num [mid ]);
23
+ root .left = rec (num , low , mid - 1 );
24
+ root .right = rec (num , mid + 1 , high );
25
+ return root ;
26
+ }
27
+ }
29
28
}
You can’t perform that action at this time.
0 commit comments