Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MrChenxxxxx opened this issue Nov 17, 2020 · 0 comments

Comments

@MrChenxxxxx
Copy link

// 可重复删除指定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,如果连续两个头部的数据是一样 的,删除的也是这个数据,这时候就有出现问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant