Question: Question 4 4 A binary string is a string consisting only of 0 s and 1 s . A substring is a contiguous group of
Question
A binary string is a string consisting only of s and
s A substring is a contiguous group of characters
within a string
Given a binary string, find the number of substrings
that contain an equal number of s and is and all
the Os and is are grouped together. Note that
duplicate substrings are also counted in the
answer. For example, has two overlapping
substrings that meet the criteria: and
Example
The substrings and have
equal numbers of s and is with all s and is
grouped consecutively. Hence, the answer is
Note that the substring has an equal
number of s and but is not counted because
not all s and is are grouped together.
Function Description
Complete the function getSubstring Count in the
editor below.
getSubstringCount has the following parameters:
s: a binary string
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
