Problem 298. No Twins?

Created by Julio

Write a function that accepts as input a vector and returns the same vector, but retaining only the first occurrence of an element whenever there is consecutive repetition of this element.

Example:

 in -> [1 2 2 2 3 4 4 3 5]
 out-> [1 2 3 4 3 5]

Tags

Problem Group

72 solvers submitted 161 solutions (2.24 solutions/solver).