Subtask 1:

Generate all possible substrings and count the number of Tokushuna substrings. The complexity of this is $O(n^2)$.

Subtask 2:

Traverse the string from beginning and if you find any $\texttt{1}$ then check the previous $\texttt{1}$ in the string.

Let the position of the current $\texttt{1}$ be $C$ and the previous $\texttt{1}$ be $P$.

If $C-P > 1$ then this is a Tokushuna string.

Complexity: $O(n)$

Statistics

80% Solution Ratio
prodip_bsmrstuEarliest, Aug '20
iammarajulFastest, 0.0s
Aimon026Lightest, 0 B
zahid147Shortest, 95B
Toph uses cookies. By continuing you agree to our Cookie Policy.