Leetcode-83 Remove Duplicates from Sorted List
#83. Remove Duplicates from Sorted List
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.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* deleteDuplicates(ListNode* head) {
ListNode* p=head;
while(p!=NULL&&p->next!=NULL)
{
if(p->val==p->next->val)
{
p->next=p->next->next;
}
else
p=p->next;
}
return head;
}
};
Leetcode-83 Remove Duplicates from Sorted List的更多相关文章
- [LeetCode] 83. Remove Duplicates from Sorted List 移除有序链表中的重复项
Given a sorted linked list, delete all duplicates such that each element appear only once. Example 1 ...
- LeetCode 83. Remove Duplicates from Sorted List (从有序链表中去除重复项)
Given a sorted linked list, delete all duplicates such that each element appear only once. For examp ...
- Java [Leetcode 83]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 only once. Exampl ...
- [leetcode]83. Remove Duplicates from Sorted List有序链表去重
Given a sorted linked list, delete all duplicates such that each element appear only once. Example 1 ...
- [LeetCode] 83. Remove Duplicates from Sorted List_Easy tag: Linked List
Given a sorted linked list, delete all duplicates such that each element appear only once. Example 1 ...
- [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 examp ...
- Leetcode 83 Remove Duplicates from Sorted List 链表
就是将链表中的重复元素去除 我的方法很简单就是如果链表的前后元素相同的话,将后一个元素删除 /** * Definition for singly-linked list. * struct List ...
- LeetCode 83. Remove Duplicates from Sorted List(从有序链表中删除重复节点)
题意:从有序链表中删除重复节点. /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode ...
随机推荐
- 测试--easymock的使用
使用场景:对于调用其它类中的方法,但是还没有编写完,使用easymock进行单元测试,它提供这些没有编写完的代码期待的默认值. 使用步骤: step1: pom引入: <dependency&g ...
- volatile不能保证原子性
1.看图自己体会 2.体会不了就给你个小程序 package cs.util; public class VolatileDemo { private volatile int count =0; p ...
- JNI使用问题记录
此文章包含Android JNI学习过程中的遇到的各种错误记录和学习总结. 1.错误:java.lang.UnsatisfiedLinkError: Native method not found: ...
- monodroid 调用 JNI Native 的一些问题
在Android版本开发的过程中,需要使用一些用JNI开发的NDK的native库.这里谈一谈踩到的坑,给大家参考. 虽然java的程序我还算熟悉,但是没有了解过 JNI Native 的开发,一般是 ...
- postman 断言解析
最近在学习postman官方文档, 顺势翻译出来,以供学习! postman断言是JavaScript语言编写的,在postman客户端指定区域编写即可. 断言会在请求返回之后,运行,并根据断言的pa ...
- php 迭代器使用
/** * 执行入口 * @author tianyunchong * Time: 4:48 pm * @return null */ public function run() { /** 遍历下所 ...
- js Date学习
Date.parse()接收一个表示日期的字符串参数(参数错误时返回NaN),返回相应日期的毫秒数.(使用自 UTC(Coordinated Universal Time,国际协调时间)1970 年 ...
- THINKPHP之连接数据库(全局配置)
- 异常处理_Maven之web项目java.lang.LinkageError
浏览器运行项目异常如下: HTTP Status 500 - type Exception report message description The server encountered an i ...
- Android6.0动态获取权限
Android6.0采用新的权限模型,只有在需要权限的时候,才告知用户是否授权,是在runtime时候授权,而不是在原来安装的时候 ,同时默认情况下每次在运行时打开页面时候,需要先检查是否有所需要的权 ...