• + 0 comments

    C++ Solution :

    long beautifulStrings(string S) {
         unordered_set<string> beautifulStrings;
    
        for (int i = 0; i < S.length(); i++) {
            for (int j = i + 1; j < S.length(); j++) {
                string candidate = S.substr(0, i) + S.substr(i + 1, j - i - 1) + S.substr(j + 1);
                beautifulStrings.insert(candidate);
            }
        }
    
        return beautifulStrings.size();
    
    }
    

    Note : Only 3 test case passed.