Google Coding Interview Question - firstDuplicate