File tree 2 files changed +21
-0
lines changed
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,19 @@ public class Solution {
121
121
}
122
122
```
123
123
124
+ #### Swift
125
+
126
+ ``` swift
127
+ class Solution {
128
+ func reverseLeftWords (_ s : String , _ n : Int ) -> String {
129
+ let leftIndex = s.index (s.startIndex , offsetBy : n)
130
+ let rightPart = s[leftIndex..< s.endIndex ]
131
+ let leftPart = s[s.startIndex ..< leftIndex]
132
+ return String (rightPart) + String (leftPart)
133
+ }
134
+ }
135
+ ```
136
+
124
137
<!-- tabs: end -->
125
138
126
139
<!-- solution: end -->
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ func reverseLeftWords( _ s: String , _ n: Int ) -> String {
3
+ let leftIndex = s. index ( s. startIndex, offsetBy: n)
4
+ let rightPart = s [ leftIndex..< s. endIndex]
5
+ let leftPart = s [ s. startIndex..< leftIndex]
6
+ return String ( rightPart) + String( leftPart)
7
+ }
8
+ }
You can’t perform that action at this time.
0 commit comments