-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCF_RemovingZeros.java
More file actions
35 lines (33 loc) · 908 Bytes
/
Copy pathCF_RemovingZeros.java
File metadata and controls
35 lines (33 loc) · 908 Bytes
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
package CP_Questions.CodeForces;
import java.util.Scanner;
class CF_RemovingZeros {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
for(int k =0;k<t;k++){
String s = sc.nextLine();
int pos1 =0;
int pos2= 0;
int c = 0;
for(int i = 0;i<s.length();i++){
if(s.charAt(i)=='1'){
pos1 = i;
break;
}
}
for(int i = s.length()-1;i>=0;i--){
if(s.charAt(i)=='1'){
pos2 =i;
break;
}
}
for(int i = pos1;i<pos2;i++){
if(s.charAt(i)=='0'){
c++;
}
}
System.out.println(c);
}
}
}