Soal
00:00

13. Remove Duplicates from Sorted Array

MudahDua pointerMicrosoftGoogle

Given an array nums sorted in non-decreasing order, remove duplicates in place so each element appears once, and return the new length.

Contoh 1:

Input: nums = [1,1,2]
Output: 2

Contoh 2:

Input: nums = [0,0,1,1,1,2,2,3,3,4]
Output: 5

Batasan:

  • 1 <= nums.length <= 3 * 10^4
  • nums is sorted in non-decreasing order.
Mode kode inti
● Tersimpan otomatisBaris 1, kolom 1