Whats wrong with my code?


#1

#include
#include
#include
#include<bits/stdc++.h>
int compute(string b){
string c=b;

for(int i=1;i<b.length();i++){
// std::rotate function 
std::rotate(b.begin(), b.begin()+i, b.end()); 
 // std::cout<<b<<i<<endl;
  int res=c.compare(b);
  if(res==0)
  return i;
}
    return 1;

}
int gcd(int a, int b)
{
if (a == 0)
return b;
return gcd(b % a, a);
}

// Function to find gcd of array of
// numbers
int findGCD(int arr[], int n)
{
int result = arr[0];
for (int i = 1; i < n; i++)
result = gcd(arr[i], result);

return result; 

}
int Solution::solve(vector &A) {
int max=0;
int arr[A.size()];
for(int i=0;i<A.size();i++){
int m=compute(A[i]);
arr[i]=m;
}
for(int i=0;i<A.size();i++){

   // cout<<arr[i]<<" ";
}
max=findGCD(arr,A.size());

//cout<<max;
return max;

}