未验证 提交 20683a21 编写于 作者: K Keqi Huang 提交者: GitHub

Merge pull request #255 from hyousi/master

fix errors in 18_01_DeleteNodeInList
......@@ -42,8 +42,11 @@ public class Solution {
}
// 删除的是尾节点
else {
// 当head遍历到tobeDelete时,指向的是同一个引用。可以直接将tobeDelete = null即可
tobeDelete = null;
ListNode ptr = head;
while (ptr.next != tobeDelete) {
ptr = ptr.next;
}
ptr.next = null;
}
return head;
......
......@@ -32,8 +32,11 @@ public class Solution {
}
// 删除的是尾节点
else {
// 当head遍历到tobeDelete时,指向的是同一个引用。可以直接将tobeDelete = null即可
tobeDelete = null;
ListNode ptr = head;
while (ptr.next != tobeDelete) {
ptr = ptr.next;
}
ptr.next = null;
}
return head;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册