leetcode_83. Remove Duplicates from Sorted List 删除单链表中的重复节点
来源:互联网 发布:linux实时守护进程 编辑:程序博客网 时间:2024/04/27 00:32
题目:
Given a sorted linked list, delete all duplicates such that each element appear only once.
For example,
Given 1->1->2
, return 1->2
.
Given 1->1->2->3->3
, return 1->2->3
.
题意:
删除单链表中重复的节点
代码:
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def deleteDuplicates(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
cur_node = ListNode(0)
cur_node = head
while cur_node != None and cur_node.next != None :
if cur_node.val == cur_node.next.val :
cur_node.next = cur_node.next.next
else :
cur_node = cur_node.next
return head
- leetcode_83. Remove Duplicates from Sorted List 删除单链表中的重复节点
- leetcode_83. Remove Duplicates from Sorted List
- LeetCode 82. Remove Duplicates from Sorted List II(删除链表中的重复节点)
- Remove Duplicates from Sorted List II 删除链表中的所有重复节点
- [leetcode]Remove Duplicates from Sorted List (删除有序节点的值重复的节点 C语言)
- LeetCode.83. Remove Duplicates from Sorted List(删除单链表中的重复元素)
- Leetcode:Remove Duplicates from Sorted List 删除单链表中重复的节点
- LeetCode 83. Remove Duplicates from Sorted List(删除重复节点)
- leetcode83---Remove Duplicates from Sorted List(删除重复元素)
- Remove Duplicates from Sorted List 删除链表中重复的元素
- (LeetCode)Remove Duplicates from Sorted List --- 链表中删除重复元素
- Remove Duplicates from Sorted List 删除链表中的重复元素,保留一次
- Remove Duplicates from Sorted List II 删除链表中的元素(不保留重复)
- Leetcode Remove Duplicates from Sorted List 删除链表中的重复元素
- LintCode Remove Duplicates from Sorted List 删除链表中的重复元素
- LintCode | Easy | 删除排序链表中的重复元素 | Remove Duplicates from Sorted List
- 112.Remove Duplicates from Sorted List-删除排序链表中的重复元素(容易题)
- [Lintcode]Remove Duplicates from Sorted List II 删除排序链表中的重复数字 II
- Scala-Spark实现RF(随机森林)
- ubuntu 下安裝pycharm
- php遇到的CURL问题
- openjudge每日推荐——7624山区建小学
- Memcached 笔记与总结(8)Memcached 的普通哈希分布算法和一致性哈希分布算法命中率对比
- leetcode_83. Remove Duplicates from Sorted List 删除单链表中的重复节点
- jquery validate 动态控制 错误信息(根据ajax 返回信息)
- 利用ITEXT操作PDF
- dynatrace 性能监测
- Flash检尸倒计时,Google和微软继续加强浏览器HTML5的功能
- 总结
- 作为一个iOS攻城狮不得不了解的网络知识
- Java工具方法总结(一)
- 虚拟内存分配和管理接口(VM allocation interfaces)