Fingerprint Interview Question

An efficient algorithm question using JS