Skip to content

Commit 260474d

Browse files
committed
Add requested changes
1 parent 1ef1d4e commit 260474d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Maths/FindMaxRecursion.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,22 @@
1717
function findMaxRecursion (arr, left, right) {
1818
const len = arr.length
1919

20-
if (len === 0 || !arr) return undefined
20+
if (len === 0 || !arr) {
21+
return undefined
22+
}
2123

2224
if (left >= len || left < -len || right >= len || right < -len) {
2325
throw new Error('Index out of range')
2426
}
2527

26-
if (left === right) return arr[left]
28+
if (left === right) {
29+
return arr[left]
30+
}
2731

2832
// x >> y == floor(x / pow(2, y))
2933
const mid = (left + right) >> 1
3034

31-
// Find the maximum of left and right
35+
// n >> m is equivalent to floor(n / pow(2, m)), floor(n / 2) in this case
3236
const leftMax = findMaxRecursion(arr, left, mid)
3337
const rightMax = findMaxRecursion(arr, mid + 1, right)
3438

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy