removeDuplicates: For every sequence of consecutive identical items in , retain only one item of that sequence.

For every sequence of consecutive identical items in , retain only one item of that sequence. Suppose we call the number of all retained items r. Then when this functions returns, elements 0 through r-1 of must contain the retained items (in the same relative order they were in originally), and the remaining elements may have whatever values you want. Return the number of retained items. Here's an example:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store