Skip to content

Instantly share code, notes, and snippets.

interface SnapshotRow {
readonly sym: string
readonly cost: number
}
/**
* Removes outdated items from the snapshot.
* @param snapshot
*/
export function stockQueue(snapshot: SnapshotRow[]): SnapshotRow[] {
/**
* Rotates the incoming matrix 90deg
* @param matrix
*/
export function rotate90deg(matrix: unknown[][]): void {
const n = matrix.length === 0 ? 0 : matrix[0].length
for (let ring = 0; ring < Math.floor(n / 2); ring++) {
for (let position = ring; position < n - ring - 1; position++) {
const backupRight = matrix[position][n - ring - 1]
@codeserk
codeserk / design-a-hashmap-without-using-any-built-in-libraries.ts
Last active January 21, 2021 14:21
Design a hashmap without using any built-in libraries. You should include the following functions
interface MapItem<T> {
readonly key: string,
readonly value: T
}
/** HashMap implementation using a 2D array */
class ArrayHashMap<T> {
/**
* Buckets where data will be stored
*