Skip to content

Instantly share code, notes, and snippets.

View fatmali's full-sized avatar
:octocat:
Coding away

Fatma Ali fatmali

:octocat:
Coding away
View GitHub Profile
@fatmali
fatmali / merge-sort.ts
Last active February 2, 2021 17:14
Merge Sort in TypeScript
function mergeSort(A: number[]): void {
const n = A.length;
if (n < 2) {
return A;
}
const mid = Math.floor(n / 2);
const left = A.slice(0, mid);
const right = A.slice(mid);
mergeSort(left);
mergeSort(right);