080.Remove Duplicates from Sorted Array II Posted on 2017-09-16 | In LeetCode Solution 1: accepted 1msIn case we need to allow k duplicates, we only change the maximum of show to k. 12345678910111213141516171819202122public int removeDuplicates(int[] nums) { if (nums.length == 0) return 0; int show = 1; int count = 1; for (int i = 1; i < nums.length; i++) { if (nums[i] == nums[i - 1]) { if (show == 2) { // change to k continue; } else { nums[count] = nums[i]; show++; count++; } } else { nums[count] = nums[i]; show = 1; count++; } } return count;}