题解
删除无序链表中值重复出现的节点
http://www.nowcoder.com/questionTerminal/fb3105d036344c6a8ecbef996e0b23a0
list_node * remove_rep(list_node * head)
{
//////在下面完成代码
if(head == nullptr || head->next == nullptr) return head;
map<int,int> Map;
list_node* cur = head;
Map[cur->val]++;
while(cur->next != nullptr) {
if(++Map[cur->next->val] > 1) {
Map[cur->next->val] = 1;
cur->next = cur->next->next;
} else
cur = cur->next;
}
return head;
}

科大讯飞公司氛围 474人发布