[LeetCode]Remove Duplicates from Sorted List(Java)

原创 2016年08月29日 19:37:14

这个题基本没什么机灵可以抖

public class Solution {
    public ListNode deleteDuplicates(ListNode head) {
        ListNode p = head;
        ListNode q = null;
        while(p!=null){
            q = p.next;
            if(q == null)
                break;
            if(p.val == q.val){
                p.next = q.next;
                q = null;
            }else{
                p = p.next;                
            }
            

            
        }
        return head;
    }
    
}

2016/8/28

版权声明:本文为博主原创文章,未经博主允许不得转载。 举报

相关文章推荐

[leetCode][Java] Remove Duplicates from Sorted List

题目: Given a sorted linked list, delete all duplicates such that each element appear only once. ...

Leetcode: Remove Duplicates from Sorted List II

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numb...

精选:深入理解 Docker 内部原理及网络配置

网络绝对是任何系统的核心,对于容器而言也是如此。Docker 作为目前最火的轻量级容器技术,有很多令人称道的功能,如 Docker 的镜像管理。然而,Docker的网络一直以来都比较薄弱,所以我们有必要深入了解Docker的网络知识,以满足更高的网络需求。

【LeetCode】Remove Duplicates from Sorted List

题目 Given a sorted linked list, delete all duplicates such that each element appear only once. For...

LeetCode 83. Remove Duplicates from Sorted List ***

题目 题意 注意 思路 代码题目 Given a sorted linked list, delete all duplicates such that each element appear o...

[leetcode]83. Remove Duplicates from Sorted List

Given a sorted linked list, delete all duplicates such that each element appear only once. For examp...

LeetCode(83)Remove Duplicates from Sorted List

题目如下: Given a sorted linked list, delete all duplicates such that each element appear only once. For...

LeetCode Remove Duplicates from Sorted List II

题目: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only dist...

LeetCode 83 - Remove Duplicates from Sorted List

Remove Duplicates from Sorted List题目链接 https://leetcode.com/problems/remove-duplicates-from-sorted...

LeetCode | Remove Duplicates from Sorted List II

题目: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinc...

[LeetCode]Remove Duplicates from Sorted List II

Question Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only dis...
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)