Skip to content

Commit a8d5386

Browse files
Fixed code style issues for Meta Binary Search with prettier
1 parent a84306c commit a8d5386

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

Search/MetaBinarySearch.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,21 @@
1212
* @returns {number} - Index of the target if found, otherwise -1.
1313
*/
1414
function MetaBinarySearch(arr, target) {
15-
const n = arr.length;
16-
if (n === 0) return -1;
15+
const n = arr.length
16+
if (n === 0) return -1
1717

18-
let pos = -1;
18+
let pos = -1
1919
for (let bit = Math.floor(Math.log2(n)); bit >= 0; bit--) {
20-
const newPos = pos + (1 << bit);
20+
const newPos = pos + (1 << bit)
2121
if (newPos < n && arr[newPos] <= target) {
22-
pos = newPos;
22+
pos = newPos
2323
}
2424
}
2525

26-
return arr[pos] === target ? pos : -1;
26+
return arr[pos] === target ? pos : -1
2727
}
2828

29-
export {MetaBinarySearch };
30-
29+
export { MetaBinarySearch }
3130

3231
// Example usage:
3332
// console.log(metaBinarySearch([1, 3, 5, 7, 9, 11], 7)); // Output: 3

0 commit comments

Comments
 (0)