Advertisement
sweet1cris

Untitled

Jan 9th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.35 KB | None | 0 0
  1. public class Solution {
  2.     public int removeDuplicates(int[] A) {
  3.         if (A == null || A.length == 0) {
  4.             return 0;
  5.         }
  6.        
  7.         int size = 0;
  8.         for (int i = 0; i < A.length; i++) {
  9.             if (A[i] != A[size]) {
  10.                 A[++size] = A[i];
  11.             }
  12.         }
  13.         return size + 1;
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement