Remove Duplicates from Sorted Array II

Medium · Arrays & Strings · about 15 minutes

Asked at Google, Amazon, Meta, Bloomberg, Microsoft.

Given a sorted integer array nums, remove duplicates in place so each value appears at most twice, keeping the order. Return k, the new length; the first k positions must hold the result. Only k is checked here.

Related guides