mirror of
https://github.com/CyC2018/Interview-Notebook.git
synced 2026-10-30 07:33:45 +00:00
Update 38. 字符串的排列.md
题目链接改为力扣中的对应题目,题目描述和代码按该题的接口调整。
This commit is contained in:
+8
-7
@@ -1,6 +1,6 @@
|
||||
# 38. 字符串的排列
|
||||
|
||||
[NowCoder](https://www.nowcoder.com/practice/fe6b651b66ae47d7acce78ffdd9a96c7?tpId=13&tqId=11180&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||
[Leetcode](https://leetcode.cn/problems/zi-fu-chuan-de-pai-lie-lcof/)
|
||||
|
||||
## 题目描述
|
||||
|
||||
@@ -9,15 +9,16 @@
|
||||
## 解题思路
|
||||
|
||||
```java
|
||||
private ArrayList<String> ret = new ArrayList<>();
|
||||
private List<String> ret = new ArrayList<>();
|
||||
|
||||
public ArrayList<String> Permutation(String str) {
|
||||
if (str.length() == 0)
|
||||
return ret;
|
||||
char[] chars = str.toCharArray();
|
||||
public String[] goodsOrder(String goods) {
|
||||
if (goods == null || goods.length() == 0)
|
||||
return new String[0];
|
||||
ret.clear();
|
||||
char[] chars = goods.toCharArray();
|
||||
Arrays.sort(chars);
|
||||
backtracking(chars, new boolean[chars.length], new StringBuilder());
|
||||
return ret;
|
||||
return ret.toArray(new String[ret.size()]);
|
||||
}
|
||||
|
||||
private void backtracking(char[] chars, boolean[] hasUsed, StringBuilder s) {
|
||||
|
||||
Reference in New Issue
Block a user