Skip to content

Commit 0bbf5ab

Browse files
committed
feat: update solutions to lcof problem: No.058
1 parent 1387c77 commit 0bbf5ab

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

lcof/面试题58 - II. 左旋转字符串/README.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
```python
3232
class Solution:
3333
def reverseLeftWords(self, s: str, n: int) -> str:
34-
n %= len(s)
3534
return s[n:] + s[:n]
3635
```
3736

@@ -40,9 +39,7 @@ class Solution:
4039
```java
4140
class Solution {
4241
public String reverseLeftWords(String s, int n) {
43-
int len = s.length();
44-
n %= len;
45-
return s.substring(n, len) + s.substring(0, n);
42+
return s.substring(n, s.length()) + s.substring(0, n);
4643
}
4744
}
4845
```
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
class Solution {
22
public String reverseLeftWords(String s, int n) {
3-
int len = s.length();
4-
n %= len;
5-
return s.substring(n, len) + s.substring(0, n);
3+
return s.substring(n, s.length()) + s.substring(0, n);
64
}
75
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
class Solution:
22
def reverseLeftWords(self, s: str, n: int) -> str:
3-
n %= len(s)
4-
return s[n:] + s[:n]
3+
return s[n:] + s[:n]

0 commit comments

Comments
 (0)