We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
仰望星空的人,不应该被嘲笑
有重复字符串的排列组合。编写一种方法,计算某字符串的所有排列组合。
示例1:
输入:S = "qqe" 输出:["eqq","qeq","qqe"]
示例2:
输入:S = "ab" 输出:["ab", "ba"]
提示:
字符都是英文字母。 字符串长度在[1, 9]之间。
来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/permutation-ii-lcci 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
全排列,直接用回溯法即可,数据量比较小,暴力完事~
var permutation = function (S) { let res = new Set() let vis = [] let dfs = (t) => { if (t.length === S.length) return res.add(t) for (let i = 0; i < S.length; i++) { if (vis[i]) continue vis[i] = true dfs(t + S[i]) vis[i] = false } } dfs('') return [...res] }
文章产出不易,还望各位小伙伴们支持一波!
往期精选:
小狮子前端の笔记仓库
访问超逸の博客,方便小伙伴阅读玩耍~
学如逆水行舟,不进则退
The text was updated successfully, but these errors were encountered:
No branches or pull requests
题目描述
有重复字符串的排列组合。编写一种方法,计算某字符串的所有排列组合。
示例1:
示例2:
提示:
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/permutation-ii-lcci
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
解题思路
全排列,直接用回溯法即可,数据量比较小,暴力完事~
最后
文章产出不易,还望各位小伙伴们支持一波!
往期精选:
小狮子前端の笔记仓库
访问超逸の博客,方便小伙伴阅读玩耍~
学如逆水行舟,不进则退
The text was updated successfully, but these errors were encountered: