This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isValidBST = (root = [5, 1, 4, null, null, 3, 6]) => { | |
for (let currentRootIndex = 0; currentRootIndex < root.length; currentRootIndex++) { | |
let isValid = true; | |
const rootValue = root[currentRootIndex]; | |
const leftChildIndex = currentRootIndex * 2 + 1; | |
const rightChildIndex = currentRootIndex * 2 + 2; | |
const leftChildValue = root[leftChildIndex] | |
const rightChildValue = root[rightChildIndex] | |
// console.log({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the main app file | |
import express from "express"; | |
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db) | |
import authenticate from "./authentication"; // middleware for doing authentication | |
import permit from "./permission"; // middleware for checking if user's role is permitted to make request | |
const app = express(), | |
api = express.Router(); | |
// first middleware will setup db connection |