Skip to content
Advertisement

How can I count subsequently equal values in an int array

I would like to count subsequently equal values in an int array and return an array with the count and another array with the value order.

E.g. i would like to transform:

JavaScript

To:

JavaScript

Can you help me achieve this?

Advertisement

Answer

This should do the job:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement