so I have this question in C:
Given an array that only contains 0's and 1's (Example: [1,1,0,0,0,0,1,0,1,0,1,1]
).
I need to find the start of a "ring interval" and the finish of the same "ring interval" (there could be many rings like that, we'll have to store the start and finish of each one in a matrix of 2 columns)
"Silence" is when at least two 0's are next to each other. (in the given array, the sub array [0,0,0,0]
is silent.
"Ring interval" is when Silence doesn't occur. (example in the given array, the sub array [1,1]
(first 2 values), and the sub array [1,0,1,0,1,1]
(the end of the array)).
So we'll have to store [0,1]
in the first row of the matrix.
then [6,11]
. since the second sub array starts at the 6th index and ends at the 11th.
I can't seem to describe it any better, it's in a different language and quite a bit more complicated than this.. i hope you understand!
Examples:
Array = [0,0,0,0,1,0,1,1,1,0,0,0,1,0,0]
Matrix would be : [4,8] [12,12]
Array = [1,0,0,1,1]
Matrix would be : [0,0] [3,4]
Thank you!