← All problemsSign in

COUNT NUMBER OF SUBSTRINGS

You are given a string S of length L consisting only of 0s and 1s. You are also given an integer K. Scan the string from left to right in such a way that the number of substrings should be returned by the program. Each substring should start with 1 and should end with 1 and in between any number of 0s can be there. For instance, if 1111 is the input then the number of strings are 1 1 1 1 11 11

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start