author: Blankj blog : http://blankj.com time : 2017/04/30 desc :
| 9 | * </pre> |
| 10 | */ |
| 11 | public class Solution { |
| 12 | public int removeDuplicates(int[] nums) { |
| 13 | int len = nums.length; |
| 14 | if (len <= 1) return len; |
| 15 | int tail = 1; |
| 16 | for (int i = 1; i < len; ++i) { |
| 17 | if (nums[i - 1] != nums[i]) { |
| 18 | nums[tail++] = nums[i]; |
| 19 | } |
| 20 | } |
| 21 | return tail; |
| 22 | } |
| 23 | |
| 24 | public static void main(String[] args) { |
| 25 | Solution solution = new Solution(); |
| 26 | int[] data = new int[]{0, 1, 1, 2, 3, 3, 3}; |
| 27 | int len = solution.removeDuplicates(data); |
| 28 | for (int i = 0; i < len; i++) { |
| 29 | System.out.print(data[i] + (i == len - 1 ? "" : ", ")); |
| 30 | } |
| 31 | } |
| 32 | } |
nothing calls this directly
no outgoing calls
no test coverage detected