JAVASCRIPT Telegram 2699
CHALLENGE

function mystery(arr, depth = 0) {
if (arr.length <= 1) return arr;

const mid = Math.floor(arr.length / 2);
const left = mystery(arr.slice(0, mid), depth + 1);
const right = mystery(arr.slice(mid), depth + 1);

const result = [];
let i = 0, j = 0;

while (i < left.length && j < right.length) {
result.push(left[i] <= right[j] ? left[i++] : right[j++]);
}

return result.concat(left.slice(i)).concat(right.slice(j));
}

const arr = [3, 1, 4, 1, 5];
console.log(mystery(arr));
4



tgoop.com/javascript/2699
Create:
Last Update:

CHALLENGE

function mystery(arr, depth = 0) {
if (arr.length <= 1) return arr;

const mid = Math.floor(arr.length / 2);
const left = mystery(arr.slice(0, mid), depth + 1);
const right = mystery(arr.slice(mid), depth + 1);

const result = [];
let i = 0, j = 0;

while (i < left.length && j < right.length) {
result.push(left[i] <= right[j] ? left[i++] : right[j++]);
}

return result.concat(left.slice(i)).concat(right.slice(j));
}

const arr = [3, 1, 4, 1, 5];
console.log(mystery(arr));

BY JavaScript


Share with your friend now:
tgoop.com/javascript/2699

View MORE
Open in Telegram


Telegram News

Date: |

It’s easy to create a Telegram channel via desktop app or mobile app (for Android and iOS): “[The defendant] could not shift his criminal liability,” Hui said. The creator of the channel becomes its administrator by default. If you need help managing your channel, you can add more administrators from your subscriber base. You can provide each admin with limited or full rights to manage the channel. For example, you can allow an administrator to publish and edit content while withholding the right to add new subscribers. To delete a channel with over 1,000 subscribers, you need to contact user support
from us


Telegram JavaScript
FROM American