Problem 60995. CumulativeCumulative Count

Given a row vector of integers with repeating values - here not all repeating values will occur in a single continuous run, create an array that is the cumulative count of the unique values -
%% Example 1
input = [4 5 5 6 11 11 11 11 20 20 20 20 20 20 20 35 5 5];
output = [1 1 2 1 1 2 3 4 1 2 3 4 5 6 7 1 1 2];
%% Example 2
input = [33 33 33 22 22 11 33 33 33 22 22 11];
output = [1 2 3 1 2 1 1 2 3 1 2 1];
Only vectorized solutions will be accepted. Check the test suite for banned functions.

Solution Stats

100.0% Correct | 0.0% Incorrect
Last Solution submitted on Oct 26, 2025

Solution Comments

Show comments

Problem Recent Solvers3

Suggested Problems

More from this Author43

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!