Skip to content

Instantly share code, notes, and snippets.

View beyond-code-github's full-sized avatar

Pete Smith beyond-code-github

View GitHub Profile
@beyond-code-github
beyond-code-github / binary-tree-terse.js
Created April 17, 2024 00:01
Initialise a simple binary tree in a terse way - Javascript
"use strict";
class TreeNode {
data;
left;
right;
constructor(data) {
this.data = data;
@beyond-code-github
beyond-code-github / binary-tree-diameter.js
Created April 17, 2024 00:23
Calculate binary tree diameter in linear time - Javascript
"use strict";
class TreeNode {
data;
left;
right;
constructor(data) {
this.data = data;
@beyond-code-github
beyond-code-github / moch-karat-studio.js
Last active April 17, 2024 08:43
Mocha test boilerplate for Karat studio - Javascript
"use strict";
const Mocha = require('mocha');
const {describe, it} = Mocha;
const chai = require('chai');
const {assert} = chai;
chai.should();
@beyond-code-github
beyond-code-github / trie-heap-words.js
Created April 17, 2024 08:45
Basic Trie implementation and problem solve with Heap - Javascript
"use strict";
const Heap = require("heap");
class Trie {
count = 0;
key = null;
// each node stores a map to its child nodes
character = {};
@beyond-code-github
beyond-code-github / min-heap-range-four-lists.js
Created April 17, 2024 08:47
Use min-heap to find lowest range spanning four lists - Javascript
"use strict";
const Heap = require("heap")
const input = [
[3, 6, 8, 10 , 15],
[1, 5, 12],
[4, 8, 15, 16],
[2, 6]
]