LeetCode 26. Remove Duplicates from Sorted Array
2016-11-20 18:27
435 查看
public class Solution { public int removeDuplicates(int[] nums) { if (nums.length == 0) return 0; int length = 1; int val = nums[0]; for (int i = 1; i < nums.length; i++) { if (nums[i] != val) { nums[length++] = nums[i]; val = nums[i]; } } return length; } }
相关文章推荐
- leetcode 26 -- Remove Duplicates from Sorted Array
- leetCode 26.Remove Duplicates from Sorted Array(删除数组反复点) 解题思路和方法
- 【Leetcode】算法题26 Remove Duplicates from Sorted Array
- (Java)LeetCode-26. Remove Duplicates from Sorted Array
- leetcode 26. Remove Duplicates from Sorted Array
- Leetcode||26.Remove Duplicates from Sorted Array
- leetcode 26: Remove Duplicates from Sorted Array
- LeetCode 26. Remove Duplicates from Sorted Array——python(easy)
- Leetcode:26 Remove Duplicates from Sorted Array
- LeetCode 26. Remove Duplicates from Sorted Array
- LeetCode 26 Remove Duplicates from Sorted Array(从已排序数组中移除重复元素)
- leetcode26~Remove Duplicates from Sorted Array
- [LeetCode]26. Remove Duplicates from Sorted Array I&II
- [leetcode]【数组】26. Remove Duplicates from Sorted Array
- leetcode--26. Remove Duplicates from Sorted Array
- leetcode 每日一题 26. Remove Duplicates from Sorted Array
- LeetCode 26. Remove Duplicates from Sorted Array
- 【leetcode】26. Remove Duplicates from Sorted Array
- [LeetCode] 26. Remove Duplicates from Sorted Array
- LeetCode 26 Remove Duplicates from Sorted Array