-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathD.java
31 lines (29 loc) · 785 Bytes
/
D.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.Scanner;
public class D {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int t=scan.nextInt();
while(t-->0)
{
String str=scan.next();
int cnt=0;
int k=0;
for(int i=0;i<str.length()-1;i++)
{
if(str.charAt(i)=='1'&&str.charAt(i+1)=='0')
{
cnt++;
}
if(str.charAt(i)=='0'&&str.charAt(i+1)=='1'&&k==1)
{
cnt++;
}
if(str.charAt(i)=='0'&&str.charAt(i+1)=='1')
{
k=1;
}
}
System.out.println(cnt+1);
}
}
}