From 32bf9991dc975f00b4bb27f03ad77ad6c07bab1c Mon Sep 17 00:00:00 2001 From: CyC2018 Date: Wed, 28 Oct 2026 13:45:05 +0800 Subject: [PATCH] =?UTF-8?q?Update=2038.=20=E5=AD=97=E7=AC=A6=E4=B8=B2?= =?UTF-8?q?=E7=9A=84=E6=8E=92=E5=88=97.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 题目链接改为力扣中的对应题目,题目描述和代码按该题的接口调整。 --- notes/38. 字符串的排列.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/notes/38. 字符串的排列.md b/notes/38. 字符串的排列.md index 149b3772..73de06ae 100644 --- a/notes/38. 字符串的排列.md +++ b/notes/38. 字符串的排列.md @@ -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 ret = new ArrayList<>(); +private List ret = new ArrayList<>(); -public ArrayList 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) {