Fingerprint interview question

An efficient algorithm question using JS