Remove Duplicates from Sorted Array - Leetcode
来源:互联网 发布:直播网站源码 编辑:程序博客网 时间:2024/06/16 15:32
public class Solution { public int removeDuplicates(int[] A) { if (A.length == 0)return 0;int i=0;for (int j = 1;j < A.length;j++) {if (A[i] != A[j])A[++i] = A[j];}return i + 1; }}
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.
Do not allocate extra space for another array, you must do this in place with constant memory.
For example,
Given input array A = [1,1,2]
,
Your function should return length = 2
, and A is now [1,2]
.
0 0
- [leetcode][array] Remove Duplicates from Sorted Array
- 【Leetcode】【Array】Remove Duplicates from Sorted Array
- LeetCode: Remove Duplicates from Sorted Array
- LeetCode: Remove Duplicates from Sorted Array II
- [Leetcode] Remove Duplicates from Sorted Array
- [Leetcode] Remove Duplicates from Sorted Array II
- LeetCode: Remove Duplicates from Sorted Array
- LeetCode: Remove Duplicates from Sorted Array II
- [Leetcode] Remove Duplicates from Sorted Array II
- leetcode 35: Remove Duplicates from Sorted Array
- [LeetCode] Remove Duplicates from Sorted Array II
- [LeetCode] Remove Duplicates from Sorted Array
- Leetcode: Remove Duplicates from Sorted Array
- [leetcode] Remove Duplicates from Sorted Array II
- [LeetCode]Remove Duplicates from Sorted Array
- [LeetCode]Remove Duplicates from Sorted Array II
- [leetcode]Remove Duplicates from Sorted Array
- [leetcode]Remove Duplicates from Sorted Array II
- 杭电OJ 1002
- c# 排行榜 自动排序
- stm32 窗口看门狗学习(一)
- android 安全问题
- 小飞鱼软件 通达OA工作流超时自动转交程序(图文)
- Remove Duplicates from Sorted Array - Leetcode
- Traverse Tree iteratively
- android 在xml中指定按钮点击事件
- Remove Duplicates from Sorted Array II - Leetcode
- OpenGL es2.0 创建颜色线圆
- JAVA学习知识点1.24之SpringMVC学习Day03
- cf287 Breaking Good
- sbobet เพื่ออนาคตที่ดี
- HTML5教程——【探秘腾讯,连接一切】