Skip to content

Instantly share code, notes, and snippets.

View esco's full-sized avatar

Esco Obong esco

View GitHub Profile
// https://leetcode.com/problems/valid-parentheses/solution/
/**
* @param {string} s
* @return {boolean}
*/
function isValid(s) {
const stack = []
const open = {
"(": true,
@esco
esco / sequence-pool.js
Created November 4, 2020 17:42
SequencePool
function SequencePool(start=0, _next=(num)=>num+1) {
let pool = [start]
function next() {
let item = pool.pop()
if (!pool.length) {
pool.push(_next(item))
}
return item
}
@esco
esco / store.js
Last active November 3, 2020 14:53
Simple Redux Store
function createStore(reducer, preloadedState) {
let state = preloadedState
const idPool = [0]
const listeners = new Map()
function getState() {
return state
}
function subscribe(listener) {
@esco
esco / leetcode-844-backspace-string-compare.js
Last active September 9, 2022 10:59
Leetcode 844. Backspace String Compare
function backspaceCompare(S, T) {
const s = evaluate(S)
const t = evaluate(T)
return s === t
};
function evaluate(str) {
const output = []
for (const char of str) {
if (char !== '#') {

Keybase proof

I hereby claim:

  • I am esco on github.
  • I am esco (https://keybase.io/esco) on keybase.
  • I have a public key ASBUFgepSRzEr-xiHms-JaDghmonHJbBE8ZwvrsQZ4bUlgo

To claim this, I am signing this object:

@esco
esco / rinkeby faucet
Created July 13, 2017 13:27
Rinkeby Faucet
0xe757E4deFDC56De8ab339fD912b16711C1B5380D
@esco
esco / gist:523f2c89aec552578899
Created August 18, 2014 17:47
p2p card game
player1 deck - d1
player2 deck - d2
d1_e == e(ki, d1)
d2_e == e(ki, d2)
p1 <-- d1, d2_e
p2 <-- d2, d1_e
seed - s
{
"name": "express-device",
"author": {
"name": "Rodrigo Guerreiro",
"url": "@rguerreiro"
},
"description": "Browser detection library, built on top of express",
"keywords": [
"browser",
"mobile",
@esco
esco / gist:5787117
Created June 15, 2013 06:11
Navigate through tabs in SublimeText using super (cmd/ctrl) + left / right arrow keys. This overrides the original behavior of jumping to the beginning or end to the line. An alternative is to use the built in ctrl + a to jump to the beginning of the line and ctrl + z to jump to the end of the line.
[
{ "keys": ["super+right"], "command": "next_view" },
{ "keys": ["super+left"], "command": "prev_view" },
{ "keys": ["ctrl+z"], "command": "move_to", "args": {"to":"hardeol", "extend":false}}
]