Implement "duplicate words" problem