Implement anagram check and stable deduplication | Google Interview Question