Number of possible sequence partitioning
-
05-11-2019 - |
سؤال
Given a sequence of 1 and 0 elements, what is the number of possible partitioning of the sequence in sub-sequences (not necessarily consecutive elements, and any number of sub-sequences are allowed) so that any sub-sequence starts and ends with a 1, and can contain an arbitrary number of 0s?
For example: Given the sequence 1 0 1 1 0 1
there are only 3 ways of partitioning the sequence:
1.
1 0 1
1 0 1
2.
1 0 0 1
1 1
3.
1 0 1
1 0 1
I am pretty sure the solution implies dynamic programming, since the solution requires a fast execution time (< 1 second).
لا يوجد حل صحيح
لا تنتمي إلى cs.stackexchange