← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Given a sorted array nums, remove the duplicates in-place such that each element appears only once. Return the new length.
Do not allocate extra space for another array; modify the input array in-place with O(1) extra memory.
Constraints:
Example 1:
Input: nums = [1, 1, 2] Output: 2 Modified array: [1, 2, _] Explanation: Return 2, first two elements are 1 and 2
Example 2:
Input: nums = [0, 0, 1, 1, 1, 2, 2, 3, 3, 4] Output: 5 Modified array: [0, 1, 2, 3, 4, _, _, _, _, _]
Source: Apple Onsite