arrow_back Back to Challenges

#26 Remove Duplicates from Sorted Array

Easy Acceptance 0%
description

Problem Description

Given an integer array `nums` sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same. Return the number of unique elements.

checklist Constraints

1 <= nums.length <= 3 * 10^4
-100 <= nums[i] <= 100
nums is sorted in non-decreasing order.

science Examples

Case #1

In: nums = [1,1,2]
Out: 2

Case #2

In: nums = [0,0,1,1,1,2,2,3,3,4]
Out: 5

Mastery Tags

Arrays Two Pointers

Hiring Companies

Adobe Amazon Apple
code

Integrated IDE

code_blocks
Coding
psychology
Aptitude