题解 | #牛群字母的集合#

牛群字母的集合

https://www.nowcoder.com/practice/5aa097cccc0241febe1054bd85ce299b

function cowCombination( s ) {
    // write code here
    let ans = []
    const tracingback = (path,idx) => {
        ans.indexOf(path.join("")) == "-1" && ans.push(path.join(""))
        for(let i=idx;i<s.length;i++) {
            path.push(s[i])
            tracingback(path,i+1)
            path.pop()
        }
    }
    tracingback([],0)
    return ans
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务