upload to gh

This commit is contained in:
specCon18 2024-05-15 16:59:36 -04:00
parent d9d8d06b8a
commit f2407a9587
33 changed files with 941 additions and 83 deletions

16
src/day1/BTBFS.ts Normal file
View file

@ -0,0 +1,16 @@
export default function bfs(head: BinaryNode<number>, needle: number): boolean {
const q: (BinaryNode<number>|null)[] = [head];
while(q.length){
const curr = q.shift() as BinaryNode<number> | undefined | null;
if(!curr){
continue;
}
if (curr.value === needle){
return true;
}
q.push(curr.left);
q.push(curr.right);
}
return false;
}