Count the occurrence of each number

```
length = len(nums)
if length<=1:
return length
i = 0
cnt = 0
for j in range(1,length):
if nums[j] == nums[i]:
cnt += 1
else:
i += 1
nums[i] = nums[j]
cnt = 0
if cnt == 1:
i += 1
nums[i] = nums[j]
return i+1
```