LeetCode 26. Remove Duplicates form Sorted Array [Easy] 发表于 2019-03-05 | 更新于 2023-07-18 | 分类于 LeetCode , Easy | 阅读次数: 题目来源:https://leetcode.com/problems/remove-duplicates-from-sorted-array/ 题目难度:Easy 解答1[Java]:123456789101112131415class Solution { public int removeDuplicates(int[] nums) { if (nums.length == 0) return 0; int head = 0; int tail = 0; for (; tail < nums.length; tail++) { if (nums[head] != nums[tail]) { nums[++head] = nums[tail]; } } return head + 1; }}