问题描述:删除链表中值一样的节点
本题收获:
1,首先判断节点是否为空
2,在链表进行循环的过程中,应该以a.next作为判断条件
3,当赋值情况不同时,不能简写判断语句
class Solution(object): def deleteDuplicates(self, head): """ :type head: ListNode :rtype: ListNode """ a = head if not a: return a while a.next: if a.val == a.next.val: a.next = a.next.next else: a = a.next return head