leetcode Remove DUplicates from Sorted List
来源:互联网 发布:大金焓湿图计算软件 编辑:程序博客网 时间:2024/06/05 10:18
题目
https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/
这是一个典型的题目
public class Solution { public int removeDuplicates(int[] A) { if(A==null)return 0; if(A.length<=1)return A.length; int begin=1; int temp=A[0]; for(int i=1;i<A.length;i++){ if(temp!=A[i]){ A[begin++]=A[i]; temp=A[i]; } } return begin; }}
还有一个是链表的删除重复元素
https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list/
public class Solution { public ListNode deleteDuplicates(ListNode head) { if(head==null||head.next==null)return head; ListNode pre=head; ListNode p=head.next; while(p!=null){ if(p.val==pre.val){ pre.next=p.next; p=p.next; }else{ pre=p; p=p.next; } } return head; }}
0 0
- Remove Duplicates from Sorted List :from LeetCode
- Leetcode - List - Remove Duplicates from Sorted List
- [leetcode][list] Remove Duplicates from Sorted List
- [leetcode][list] Remove Duplicates from Sorted List
- LeetCode: Remove Duplicates from Sorted List
- LeetCode: Remove Duplicates from Sorted List II
- [Leetcode] Remove Duplicates from Sorted List
- [Leetcode] Remove Duplicates from Sorted List II
- LeetCode: Remove Duplicates from Sorted List
- LeetCode: Remove Duplicates from Sorted List II
- [Leetcode] Remove Duplicates from Sorted List II
- leetcode 37: Remove Duplicates from Sorted List
- [leetcode] Remove Duplicates from Sorted List II
- [LeetCode] Remove Duplicates from Sorted List II
- [LeetCode] Remove Duplicates from Sorted List
- [leetcode] Remove Duplicates from Sorted List
- [leetcode] Remove Duplicates from Sorted List II
- [LeetCode]Remove Duplicates from Sorted List
- Android IntentFilter 匹配原则浅析
- 存储过程输出调试信息
- 【转】献给写作者的 Markdown 新手指南
- 火狐上调试
- iOS技术浅谈之第一篇 (前言篇)
- leetcode Remove DUplicates from Sorted List
- Oracle Function ---- 函数
- iOS UILable自适应撑高即UITableViewCell的高度自适应改变
- 六步实现Rest风格的API
- Linux netstat命令详解
- 怎么才能把PDF文件转换成PPT格式
- java转换json需要导入的jar包,org/apache/commons/lang/exception/NestableRuntimeException
- 【SICP练习】84 练习2.56
- android SeekBar 的基本应用和自定义SeekBar