Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Rampaging

Azriel Axighi

💭
Rampaging
View GitHub Profile
@Axighi
Axighi / buildBinaryTreeFromArray.js
Last active Apr 20, 2021
Convert LeetCode Array Binary Tree To Tree Structure
View buildBinaryTreeFromArray.js
// Definition for a binary tree node.
function TreeNode(val, left, right) {
this.val = val === undefined ? 0 : val;
this.left = left === undefined ? null : left;
this.right = right === undefined ? null : right;
}
/**
* @param {Array<Number>} nodes
* @return {null | TreeNode}
View asyncRunner.ts
class AsyncTaskRunner {
private aborted: boolean;
ag: () => AsyncGenerator<any, void, unknown>;
constructor(tasks: Promise<any>[]) {
this.aborted = false;
this.ag = async function* asyncGenerator() {
for (let i = 0; i < tasks.length; i++) {
try {
const res = await tasks[i];