https://leetcode.com/problems/remove-duplicates-from-sorted-array/
class Solution { public int removeDuplicates(int[] nums) { if (nums.length <= 1) { return nums.length; } //็ฌฌไธไธช็ปๅฏนๅฏไปฅไฟ็๏ผi่กจ็คบๆๅไธไธชๅฏไปฅไฟ็็ๆฐๅญ int i = 0; for (int j = 1; j < nums.length; j++) { if (nums[i] != nums[j]) { nums[++i] = nums[j]; } } return i + 1; } }
Last updated 2 years ago