File tree 3 files changed +3
-9
lines changed
3 files changed +3
-9
lines changed Original file line number Diff line number Diff line change 31
31
``` python
32
32
class Solution :
33
33
def reverseLeftWords (self , s : str , n : int ) -> str :
34
- n %= len (s)
35
34
return s[n:] + s[:n]
36
35
```
37
36
@@ -40,9 +39,7 @@ class Solution:
40
39
``` java
41
40
class Solution {
42
41
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);
46
43
}
47
44
}
48
45
```
Original file line number Diff line number Diff line change 1
1
class Solution {
2
2
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 );
6
4
}
7
5
}
Original file line number Diff line number Diff line change 1
1
class Solution :
2
2
def reverseLeftWords (self , s : str , n : int ) -> str :
3
- n %= len (s )
4
- return s [n :] + s [:n ]
3
+ return s [n :] + s [:n ]
You can’t perform that action at this time.
0 commit comments