From e717e33b9e36f597b9f5365639d9582b4c66b6a9 Mon Sep 17 00:00:00 2001 From: CyC2018 Date: Wed, 28 Oct 2026 13:45:07 +0800 Subject: [PATCH] =?UTF-8?q?Update=2058.2=20=E5=B7=A6=E6=97=8B=E8=BD=AC?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 题目链接改为力扣中的对应题目,题目描述和代码按该题的接口调整。 --- notes/58.2 左旋转字符串.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/notes/58.2 左旋转字符串.md b/notes/58.2 左旋转字符串.md index 576d83c9..cd9c576c 100644 --- a/notes/58.2 左旋转字符串.md +++ b/notes/58.2 左旋转字符串.md @@ -2,7 +2,7 @@ ## 题目链接 -[牛客网](https://www.nowcoder.com/practice/12d959b108cb42b1ab72cef4d36af5ec?tpId=13&tqId=11196&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github) +[Leetcode](https://leetcode.cn/problems/zuo-xuan-zhuan-zi-fu-chuan-lcof/) ## 题目描述 @@ -22,12 +22,12 @@ Output: 先将 "abc" 和 "XYZdef" 分别翻转,得到 "cbafedZYX",然后再把整个字符串翻转得到 "XYZdefabc"。 ```java -public String LeftRotateString(String str, int n) { - if (n >= str.length()) - return str; - char[] chars = str.toCharArray(); - reverse(chars, 0, n - 1); - reverse(chars, n, chars.length - 1); +public String dynamicPassword(String password, int target) { + if (target >= password.length()) + return password; + char[] chars = password.toCharArray(); + reverse(chars, 0, target - 1); + reverse(chars, target, chars.length - 1); reverse(chars, 0, chars.length - 1); return new String(chars); }