Skip to content

Commit 80cfda1

Browse files
committed
Merge branch 'main' of github.com:w2xi/leetcode
2 parents bd64b5e + 0ac5472 commit 80cfda1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

algorithms/convert-sorted-array-to-binary-search-tree.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
var sortedArrayToBST = function (nums) {
1414
// 需要分割数组,产生了额外的内存开销
1515
if (nums.length == 0) return null;
16-
const mid = Math.floor(nums.length / 2);
16+
const mid = nums.length >> 1;
1717
const root = new TreeNode(nums[mid]);
1818

1919
root.left = sortedArrayToBST(nums.slice(0, mid));

0 commit comments

Comments
 (0)