Bulls And Cows Leetcode

https://leetcode.com/explore/featured/card/september-leetcoding-challenge/555/week-2-september-8th-september-14th/3455/
Where Iam going wrong??

    int n= (int)secret.size();
    int m = (int)guess.size();
    int ct=0;
    for(int i=0;i<n and i<m;i++)
    {
        if(secret[i]==guess[i])ct++;
    }
    map<char,int>sc;
    map<char,int>gu;
    for(auto i:guess)gu[i]++;
    for(auto i:secret)sc[i]++;
    //
 int val=0;
    for(auto i:sc)
    {
        val += min(i.second,gu[i.first]);
    }
    string ans;
    val = val-ct;
   ans+=to_string(ct);
    ans+='A';
    ans+=to_string(val);
    ans+='B';
    return ans;

when you declared maps sc and gu, you have not mentioned their size but just after that (declaration) you are using them and I think gu[i] is not a valid statement, because gu is not a vector it is 2-dimensional data structure so you need to specify which value to increase.
and also this question does not include so many complications.
It is a bit easier, you can have a look at my solution

string getHint(string secret, string guess) {
vector data1(10,0);
vector data2(10,0);
int b=0,c=0;
for(int i=0;i<secret.length();++i){
data1[secret[i]-‘0’]++;
data2[guess[i]-‘0’]++;
if(secret[i]==guess[i])
++b;
}
for(int i=0;i<10;++i){
c+=(min(data1[i],data2[i]));
}
c-=b;
return to_string(b)+“A”+to_string©+“B”;
}

Its perfect. He’s using iterator, which translates to gu[guess[i]]++. Same for sc[secret[i]]++. He’s calculating frequency, the same you are doing with vector