Two Pointers: Remove Duplicates from Sorted Array II

Rohan Arora
Red Coder Publications
Mar 24, 2021

Given a sorted array, remove the duplicates in place such that each element can appear at most twice and return the new length.

Do not allocate extra space for another array, you must do this in place with constant memory.

Read complete question here β€” https://www.interviewbit.com/problems/min-steps-in-infinite-grid/

Asked in Expedia, Microsoft.

Watch the complete video to understand the algorithm completely.

Check out this easy code.

If you find this article helpful, give me a clap πŸ‘.

Have any better solution? Share it in the comment section.

Check out Red Coder Publication for more solutions of InterviewBit, Leetcode, Codeforces, etc β€” Click here

Follow me for more articles πŸ˜ƒ

--

--

Rohan Arora
Red Coder Publications

Competitive Programmer and Software Developer. Open for opportunities β€” rohanaroramedium@gmail.com