83. Remove Duplicates from Sorted List
链表中相邻的重复的数字只保留一个
Example 1:Input: 1->1->2 Output: 1->2 Example 2:Input: 1->1->2->3->3 Output: 1->2->3
只要一次遍历如果某个结点值和前一个结点值相同删掉即可
class Solution { public:ListNode* deleteDuplicates(ListNode* head) {if(head==NULL){return head;}ListNode *a, *b, *temp;a = head;while(a!=NULL && a->next!=NULL){b = a->next;if(a->val==b->val){a->next=b->next;//注释部分是用来删除空间的// delete b;}else{a=b;}}return head;} };
转载于:https://www.cnblogs.com/mangmangbiluo/p/10487216.html
83. Remove Duplicates from Sorted List相关推荐
- [勇者闯LeetCode] 83. Remove Duplicates from Sorted List
[勇者闯LeetCode] 83. Remove Duplicates from Sorted List Description Given a sorted linked list, delete ...
- [leetcode]83.Remove Duplicates from Sorted List
题目 Given a sorted linked list, delete all duplicates such that each element appear only once. Exampl ...
- Leet Code OJ 83. Remove Duplicates from Sorted List [Difficulty: Easy]
题目: Given a sorted linked list, delete all duplicates such that each element appear only once. For e ...
- LeetCode 83. Remove Duplicates from Sorted List
题目: Given a sorted linked list, delete all duplicates such that each element appear only once. For e ...
- leetcode python3 简单题83. Remove Duplicates from Sorted List
1.编辑器 我使用的是win10+vscode+leetcode+python3 环境配置参见我的博客: 链接 2.第八十三题 (1)题目 英文: Given a sorted linked list ...
- leetcode(83)—— 删除已排序链表重复元素(Remove Duplicates from Sorted List)
Remove Duplicates from Sorted List 官方答案(Java): Remove Duplicates from Sorted List 思路:维护两指针(ListNode ...
- 2016.5.57—— Remove Duplicates from Sorted List
Remove Duplicates from Sorted List 本题收获: 指针: 不管什么指针在定义是就初始化:ListNode *head = NULL; 如果给head指针赋值为第一个no ...
- Remove Duplicates from Sorted Array II -- LeetCode
原题链接: http://oj.leetcode.com/problems/remove-duplicates-from-sorted-array-ii/ 这道题跟Remove Duplicates ...
- LeetCode集锦(八) - 第26题 Remove Duplicates From Sorted Array
LeetCode集锦(八) - 第26题 Remove Duplicates From Sorted Array 问题 Given a sorted array nums, remove the du ...
最新文章
- Column 'Column Name' does not belong to table Table
- 北风设计模式课程---13、享元模式
- rxjs里scan operator的执行研究
- mysql各种联结的区别_mysql几种连接方式区别
- 服务器运维一般的故障率,服务器平均故障率
- mt19937 -- 高质量随机数
- centos7 network网络服务重启报错failed to start lsb
- Python_主成分分析
- rtsp转rtmp服务linux,ubuntu安装流媒体服务器(nginx+rtmp,rtsp转rtmp,rtsp转m3u8)
- php怎么写显示商品图片,php – Woocommerce显示带有产品图片的产品
- 大规模数据作成时的注意点。
- requestAnimationFrame用法
- 从源码角度分析android事件分发处理机制
- Android中图片大小和屏幕密度的关系讲解
- OSX: Scripts,让BootCamp在不论什么Mac上支持生成Windows7的USB安装盘
- Hbuilder X 开发APP指南
- html字体制作,用@font-face实现网页特殊字符(制作自定义字体)
- c语言处理nc程序,NC程序的语言问题
- 苹果恢复出厂设置系统也会还原吗_手机出毛病了就恢复出厂设置,会损伤手机吗?影响有多大呢...
- 立夏游雪上,赏奇花,正当时:天台九遮山
热门文章
- Asp.net MVC调试-使用IP监听
- Grpc C# 入门
- pyHook 转码问题-MouseSwitch() missing 8 required positional arguments...,原因及解决办法
- 飞思卡尔智能车iar工程常见问题
- jsp mysql在线考试系统源码_课内资源 - 基于JSP和MYSQL数据库实现的在线考试系统...
- js写css3过渡前端,web前端vue之CSS过渡效果示例
- pip安装时报错:以一种访问权限不允许的方式做了一个访问套接字的尝试
- Jmeter之Bean shell使用(五)
- Happy Matt Friends(HDU5119 + dp)
- python—迭代器