Equinix Interview Question

Basic JS question, hard LC problem