package leetcode_50; /*** * * @author pengfei_zheng * 移除有序数组中的重复元素 */ public class Solution26 { public int removeDuplicates(int[] nums) { if(nums.length==0) return 0; int i = 1; for (int n : nums) if (n > nums[i-1])//满足则说明不重复 nums[i++] = n;//更新i return i; } }
LeetCode 26 Remove Duplicates from Sorted Array (移除有序数组中重复数字)
原文:http://www.cnblogs.com/zpfbuaa/p/6527377.html