The success of IEEE code-quest depends on number of times the factor is present in a…
- User
The success of IEEE code-quest depends on number of times the factor is present in a given string.Help core members to find them Factor of string is defined as a substring.In this case it's '01'. Input First line of input contains an integer T, denoting the number of test cases. Then follows description of T cases.Each line of input is a binary form.
Output Print the number of times the factor is present in a given string.
Constraints
1 <= S <= 100000
1 <= T <= 50Example Input: 1 1001010100001
Output: 4
Assistant
T = int(input()) for _ in range(T): s = input().strip() count = 0 for i in range(len(s) - 1): if s[i] == '0' and s[i+1] == '1': count += 1 print(count)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.