# Issue in HOWMANYMAX

I gave this solution to HOWMANYMAX (How Many Maximums Practice Coding Problem - CodeChef)

include <stdio.h>

int main(void) {
// your code goes here
int T;
scanf(“%d”, &T);
while (T–){
int N = 0;
scanf(“%d”, &N);
int size_S = N - 1;
int S[size_S];
for (int i = 0; i < size_S; i++){
scanf(“%d”, &S[i]);
}
int max = 1;
for (int i = 0; i < size_S; i++){
if (S[i] == 1 && S[i+1] ==0){
max ++;
}
}
printf(“%d\n”, max);
}
}

Why is it giving output as
1
1
1
for the input
3
2
0
7
000111
6
11100

whereas it is giving the correct output in other compilers. I’m unable to understand

@a22189_goswami
here refer my c++ code for better understanding

``````#include <bits/stdc++.h>
using namespace std;

int main() {
// your code goes here
int t;
cin>>t;
while(t--)
{
int n;
int ans=0;
cin>>n;
string s;
cin>>s;
for(int i=1;i<n-1;i++)
{
if(s[i]!=s[i-1]and s[i-1]=='0')
{
ans++;
}
}
if(s[0]=='1')
ans++;
if(s[n-2]=='0')
ans++;
cout<<ans<<endl;
}

}``````

There is a problem with how you are taking input!
You can try to print the array and check!

Yes, I got it, thanks a lot. Now, I’m taking the input as a string and the code works perfectly:
include <stdio.h>

int main(void) {
// your code goes here
int T;
scanf(“%d”, &T);
while (T–){
int N = 0;
scanf(“%d”, &N);
int size_S = N - 1;
char S[size_S];
scanf(“%s”, &S);
int max = 1;
for (int i = 0; i < size_S; i++){
if (S[i] == ‘1’ && S[i+1] == ‘0’){
max ++;
}
}
printf(“%d\n”, max);
}
}