Javascript solution


  • 0
    R
    var findPermutation = function(s) {
        var ret = []
        for(let i = 0; i <= s.length; i++) {
            if(i == s.length || s[i] == 'I') {
                for(let j = i + 1, lenTemp = ret.length; j > lenTemp; --j) 
                    ret.push(j)
            }
        }
        return ret
    };
    

Log in to reply
 

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