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 knightMoves = [ | |
[-1, 2], | |
[1, 2], | |
[-2, 1], | |
[2, 1], | |
[-2, -1], | |
[2, -1], | |
[-1, -2], | |
[1, -2], | |
]; |
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
class Tree { | |
constructor(root = null) { | |
this.root = root; | |
} | |
// 💭 -------------------------------------------------------------- | |
// 💭 Static Private | |
static #_sortedArrayToBSTInternal(sortedArray, start, end) { | |
if (start > end) return null; |
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
class CycloneHashSet { | |
constructor(capacity, loadFactor, name) { | |
this.buckets = new Array(capacity).fill(null).map(() => []); | |
this.loadFactor = loadFactor; | |
this.numberOfKeys = 0; | |
this.name = name; | |
this.setSize = capacity; | |
} | |
/** |
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
/** | |
* Class representing a single node in a linked list. | |
* Each node holds data and a reference to the next node in the list. | |
*/ | |
class Node { | |
/** | |
* Create a node. | |
* @param {*} data - The data to store in the node. This can be of any type. | |
*/ | |
constructor(data) { |
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
/** | |
* Class representing a hash map designed to handle strings. | |
*/ | |
class HashMap { | |
constructor(name, capacity, loadFactor) { | |
this.buckets = new Array(capacity).fill(null).map(() => []); | |
this.loadFactor = loadFactor | |
this.mapSize = capacity; | |
this.name = name; | |
this.numEntries = 0; |
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 testArray1 = [3, 2, 1, 13, 8, 5, 0, 1]; | |
const testArray2 = [105, 79, 100, 110, 3]; | |
function merge(leftHalfOfArray, rightHalfOfArray) { | |
let mergedArray = []; | |
let leftHalfPointer = 0; | |
let rightHalfPointer = 0; | |
let mergedPointer = 0; |