class Solution:
    def remove_duplicates(self, nums):
        if len(nums) <= 2:
            return len(nums)
        
        j = 1
        for i in range(2, len(nums)):
            if nums[i] > nums[j - 1]:
                j += 1
                nums[j] = nums[i]
        
        j += 1
        for _ in range(j, len(nums)):
            nums.pop()
        
        return j

solution = Solution()
nums = [1,1,1,2,2,3]
print(solution.remove_duplicates(nums))
print(nums)