Leetcode 83. Remove Duplicates from Sorted List 移除重复 链表版 解题报告
来源:互联网 发布:常用生物数据分析软件 编辑:程序博客网 时间:2024/09/21 06:22
1 解题思想
昨天的那道题反而是2,今天的反而是1,leetcode的编排很奇怪
Leetcode 82. Remove Duplicates from Sorted List II 移除重复 链表版-2
直接删除就好了,不多说,太简单。
上一题是遇到重复的不增加,这道题是只增加一个,一样的
2 原题
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.
Subscribe to see which companies asked this question
3 AC解
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * }直接删除头就好 */public class Solution { public ListNode deleteDuplicates(ListNode head) { ListNode p=head; while(p!=null){ while(p.next!=null && p.val==p.next.val){ p.next=p.next.next; } p=p.next; } return head; }}
0 0
- Leetcode 83. Remove Duplicates from Sorted List 移除重复 链表版 解题报告
- Leetcode 82. Remove Duplicates from Sorted List II 移除重复 链表版-2 解题报告
- Leetcode #26. Remove Duplicates from Sorted Array 移除重复数字 解题报告
- Leetcode 80. Remove Duplicates from Sorted Array II 重复移除 解题报告
- [leetcode] 83. Remove Duplicates from Sorted List 解题报告
- 【LeetCode】remove-duplicates-from-sorted-list and remove-duplicates-from-sorted-list ii 解题报告
- [leetcode] 82. Remove Duplicates from Sorted List II 解题报告
- [LeetCode] Remove Duplicates from Sorted List 解题报告
- 【LeetCode】Remove Duplicates from Sorted List 解题报告
- [Leetcode] 82. Remove Duplicates from Sorted List II 解题报告
- Remove Duplicates from Sorted List 从链表里移除重复元素 @LeetCode
- 【leetcode 移除有序序列重复数字】Remove Duplicates from Sorted Array(List) I(II)
- Remove Duplicates from Sorted List II 链表移除重复值@LeetCode
- [LeetCode]83.Remove Duplicates from Sorted List
- [Leetcode] 83. Remove Duplicates from Sorted List
- LeetCode --- 83. Remove Duplicates from Sorted List
- [leetcode] 83.Remove Duplicates from Sorted List
- LeetCode 83. Remove Duplicates from Sorted List
- PyQt5:ToggleButton开关按钮(24)
- 反射
- 文件的上传、下载
- FragmentPagerAdapter与FragmentStatePagerAdapter区别
- PyQt5:QSlider滑块、QLabel标签(25)
- Leetcode 83. Remove Duplicates from Sorted List 移除重复 链表版 解题报告
- 七. ubuntu更改主机名
- 提交Eclipse代码到Github
- PyQt5:QProgressBar进度条(26)
- Android lint 定制规则
- iOS快速开发框架--Bee Framework
- leetcode_c++:Unique Paths(062)
- 与 '\r' 字符的两次交锋
- PyQt5:QCalendarWidget日历部件(27)