Problem 40. Reverse Run-Length Encoder
Given a "counting sequence" vector x, construct the original sequence y.
A counting sequence is formed by "counting" the entries in a given sequence. This is sometimes called run-length encoding.
For example, the sequence
x = 2, 5, 1, 2, 4, 1, 1, 3
can be read as
Two 5's, one 2, four 1's, one 3
which translates to
y = 5, 5, 2, 1, 1, 1, 1, 3
So y is the reconstructed vector that corresponds to the counting sequence x.
For this problem, all elements in the sequences x and y will be in the range from 1 to 9.
Solution Stats
Problem Comments
-
5 Comments
Show
2 older comments
Sanzhar Askaruly
on 5 Jul 2019
easy
subbarao satha
on 2 Mar 2020
useful challenge
赛鼎 薛华
on 11 Jul 2022
useful
Solution Comments
Show commentsProblem Recent Solvers2639
Suggested Problems
-
The Goldbach Conjecture, Part 2
2371 Solvers
-
344 Solvers
-
Back to basics 11 - Max Integer
792 Solvers
-
Cell Counting: How Many Draws?
2139 Solvers
-
Reverse the elements of an array
1050 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!