In this question we have to find the no of substrings starting and ending both with '1'.
for input string (str) : 10001
the substrings are : 10001 (str[0] to str[4]), 1 (str[0]), 1 (str[4]). Hence, answer is 3.
Note that a substring of length one which contains the character '1' is also starting and ending with 1, hence it will also add to our answer.

preda2or13:39, Oct 12Shubham Kumar GuptaIn this question we have to find the no of substrings starting and ending both with '1'.

for input string (str) : 10001

the substrings are : 10001 (str[0] to str[4]), 1 (str[0]), 1 (str[4]). Hence, answer is 3.

Note that a substring of length one which contains the character '1' is also starting and ending with 1, hence it will also add to our answer.

Please make sure the answer is not too short