Help me in solving ALBS problem

My issue

where is the problem in my code
can you help me find it

My code

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

int main() {
	// your code goes here
	int n;
	cin >> n;
	for (int i=0; i<n; i++){
	    int N;
	    cin >> N;
	    char arr[N];
	    for (int j=0; j<N; j++){
	        cin >> arr[j];
	    }
	    if (N==1){
	        cout << 0 << endl;
	        continue;
	    }
	    bool flag = true;
	    for (int j=1; j<N; j++){
	        if (arr[j] == arr[j-1]){
	            flag = false;
	            cout << j << endl;
	            break;
	        } 
	    }
	    if (flag){
	        cout << 0 << endl;
	    }
	}
}

Problem Link: Alternating Binary String Practice Coding Problem - CodeChef

Don’t do like that
The concept of question is just simple
If a(i)==a(i-1) count++
Loop start from i=1 to i<n
The output is count

I don’t write properly because I typing in my phone
So understand this and if u unable to understand write code that I told above then you will understand

Thankyou

thanks
got it