I have a string which contains only 0 and 1. I need to encode it in a form of ranges of 1's.
Example input:
01101110
Example output:
[[1,2], [4,6]]
Update: Need to produce [begin,end] array of 1's sequence indexes.
As per example:
First sequence of 1's starts at index 1 and finishes at index 2.
Second sequence starts at index 4 and finishes at index 6
Minimum length of sequence is 1. So "1"
input produces [[0,0]]
output
How should I do it?