Coding Interview Tutorial 43: Remove Duplicates from Sorted Array II [LeetCode]

preview_player
Показать описание
Learn how to remove duplicates from a sorted array in place, allowing any element to appear at most twice.

The time complexity of the solution is O(n), where n is the length of the input array.

This is an important programming interview question, and we use the LeetCode platform to solve this problem.
Рекомендации по теме
Комментарии
Автор

This doesnt work if the input is lets say
[1]
to fix this start the left and right pointers at index 1 and in the if statement add l == 1

harsha.
Автор

Thank you! This solution is so concise, and it helps a lot! But what if the input was [0, 0, 0]?

weihu
Автор

great solution, but plz make video little bit longer and with proper explanation and also dry run for atleast one test case

diveshanand