Two Pointers: Remove Duplicates from Sorted Array II
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 π