Custom Testcase passed fine, get Runtime Error when submit(same test case)?


  • 0
    D

    My solution passed test case "11", "10" when using Custom Testcase. But for the same test case, it gives Runtime Error. Anyone has any ideas?

    Thanks

    string getHint(string secret, string guess) {
            vector<int> tb(10,0);
            int countA = 0, countTotal = 0;
            for (int i = 0; i < secret.size(); ++i) {
                if (secret[i] == guess[i]) 
                    ++countA;
                ++tb[secret[i]];
            }
            
            // count total matches
            for (int i = 0; i < guess.size(); ++i) {
                if (tb[guess[i]] > 0) {
                    ++countTotal;
                    --tb[guess[i]];
                }
            }
            return to_string(countA) + "A" + to_string(countTotal-countA) + "B";
        }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.