Clean c++ solution


  • 0
    vector<int> findPermutation(string s) {
            int size = s.size(), start = 0, num = 1;
            vector<int> result(size + 1);
            for (int i = 0; i <= size; i++) {
                if (i == size || s[i] == 'I') {
                    for (int j = i; j >= start; j--)
                        result[j] = num++;
                    start = i + 1;
                }
            }
            return result;
        }
    

Log in to reply
 

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