Saturday, July 16, 2016

Remove duplicates from Sorted Array

July 16, 2016

Problem statement:
Remove duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appears only once and return the new length.
Note that even though we want you to return the new length, make sure to change the original array as well in place
Do not allocate extra space for another array, you must do this in place with constant memory.
Example:
Given input array A = [1,1,2],
Your function should return length = 2, and A is now [1,2].

First practice:

https://gist.github.com/jianminchen/f7156b033b783b3a01c2ad2cb3d1b313


1 comment: