MCPcopy Create free account
hub / github.com/Ayush7614/Daily-Coding-DS-ALGO-Practice / clusters

Method clusters

Codeforces/Java/Sleep_Cycle.java:4–24  ·  view source on GitHub ↗
(String s,int h,int a[])

Source from the content-addressed store, hash-verified

2 class MyClass {
3 // forming array which contains the count of continuous zeros
4 public static void clusters(String s,int h,int a[])
5 {int c1=0;
6 int c2=0;
7 for(int x=0;x<h;x++)
8 {
9 char ch=s.charAt(x);
10 if(ch=='0')
11 {
12 c1=c1+1;
13 }
14 else{
15 if(c1!=0)
16 a[c2]=c1;
17 c2=c2+1;
18 c1=0;
19 }
20 }
21 if(c1>0)
22 a[c2]=c1;
23
24 }
25 public static void main(String args[]) {
26 Scanner sc=new Scanner(System.in);
27 int t=sc.nextInt();

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected