deleteByNode可以提前结束
当删除节点为头结点的时候可以不用进行循环查找要删除节点的前驱节点
This commit is contained in:
parent
181f721ad6
commit
04c7c20b68
@ -87,6 +87,7 @@ public class SinglyLinkedList {
|
||||
|
||||
if (p == head) {
|
||||
head = head.next;
|
||||
return;
|
||||
}
|
||||
|
||||
Node q = head;
|
||||
|
Loading…
Reference in New Issue
Block a user