For this Question: Given an array of N strings, find the longest common prefix among all strings present in the array.The fist line of each test contains a single integer N. Next line has space-separated N strings.

Constraints:-
1 <= N <= 10^3
1 <= |S| <= 10^3
Print the longest common prefix as a string in the given array. If no such prefix exists print "-1"(without quotes).Sample Input:
4
geeksforgeeks geeks geek geezer

Sample Output:
gee

Sampel Input:-
3
a b c

Sample Output:-
-1, I have written this Solution Code: #include <bits/stdc++.h>
using namespace std;


int main(){
int n;
cin>>n;
string a[n];
int x=INT_MAX;
for(int i=0;i<n;i++){
    cin>>a[i];
    x=min(x,(int)a[i].length());
}
string ans="";
for(int i=0;i<x;i++){
    for(int j=1;j<n;j++){
        if(a[j][i]==a[0][i]){continue;}
        goto f;
    }
    ans+=a[0][i];
}
f:;
if(ans==""){cout<<-1;return 0;}
cout<<(ans);
}
, In this Programming Language: C++, Now tell me if this Code is compilable or not?