83-Remove Duplicates From Sorted List
100-Same Tree | Links:
题意
Given a sorted linked list, delete all duplicates such that each element appear only once.
Example 1:
Input: 1->1->2
Output: 1->2
Example 2:
Input: 1->1->2->3->3
Output: 1->2->3
思路
- 链表
- 遍历:判断cur.val == cur.next.val
- 重复:连到下一个点
- 不重复:往后走
分析:
- Time: O(n)
- Space: O(1)