Skip to content

Instantly share code, notes, and snippets.

View iJustErikk's full-sized avatar

Erik Awwad iJustErikk

View GitHub Profile
// recursively divides then merges
const mergeSort = (curSubArr) => {
if (curSubArr.length <= 1) return curSubArr;
const middle = Math.floor(curSubArr.length / 2);
const left = curSubArr.slice(0, middle);
const right = curSubArr.slice(middle);
return merge(mergeSort(left), mergeSort(right));
};
const merge = (left, right) => {
let pointerA = 0;
@iJustErikk
iJustErikk / naivesubstring.py
Created November 24, 2020 19:02
Naive Substring Algorithm
def indexOf(text, string):
for i in range(len(text)):
didBreak = False
for j in range(len(string)):
if (i+j >= len(text)):
didBreak = True
break
if (text[i + j] != string[j]):
didBreak = True
break