Implement "Duplicate Words" problem