public int RemoveDuplicates(int[] nums)
{
int i=0,j=1;
while(j<nums.Length)nums[++i]=nums[j++]==nums[--i] ? nums[i]:nums[j+i-++i];
return i+1;
}
i am freindly code below
public class Solution
{
public int RemoveDuplicates(int[] nums)
{
int i=0,j=1;
while(j<nums.Length)
{
if(nums[j]==nums[i]) j++;
else nums[++i] =nums[j++];
}
return i+1;
}
}