[LeetCode]Remove Duplicates from Sorted Array

This answer seems to beat 99.24% of cpp submissions.

class Solution {
public:  
    int removeDuplicates(vector<int>& nums) {
        int i, j;

        if(nums.size() <= 1) {
            return nums.size();
        }

        for(i = j = 1; j < nums.size(); j++) {
            if(nums[j] != nums[j - 1]) {
                nums[i++] = nums[j];
            }
        }

        return i;
    }
};