-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherasingzeroes.java
More file actions
39 lines (38 loc) · 1.03 KB
/
erasingzeroes.java
File metadata and controls
39 lines (38 loc) · 1.03 KB
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
32
33
34
35
36
37
38
39
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
import java.util.List;
public class erasingzeroes {
static int mod = (int) 1e9 + 7;
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
String s=sc.next();
boolean z=false;
int first=s.length();
for(int i=0;i<s.length();i++){
if(s.charAt(i)=='1'){
first=i;
break;
}
}
int last=-1;
for(int i=s.length()-1;i>=0;i--){
if(s.charAt(i)=='1'){
last=i;
break;
}
}
int total=0;
for(int i=first;i<=last;i++){
if(s.charAt(i)=='0')total++;
}
System.out.println(total);
}
}
}