Skip to content

java/06_linkedlist/SinglyLinkedList.java---deleteByValue中可重复删除指定value的代码逻辑有一处错误 #496

Open
@MrChenxxxxx

Description

@MrChenxxxxx

// 可重复删除指定value的代码
/*
if (head != null && head.data == value) {
head = head.next;
}
Node pNode = head;
while (pNode != null) {
if (pNode.next.data == data) {
pNode.next = pNode.next.next;
continue;
}
pNode = pNode.next;
}
*/

if (head != null && head.data == value) 这里的if应该改为while,如果连续两个头部的数据是一样 的,删除的也是这个数据,这时候就有出现问题

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions