We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 55fb4c1 commit 998e4e3Copy full SHA for 998e4e3
lcof/面试题05. 替换空格/README.md
@@ -151,6 +151,36 @@ function replaceSpace(s: string): string {
151
}
152
```
153
154
+### **Rust**
155
+
156
+- 使用 `replace()`
157
158
+```rust
159
+impl Solution {
160
+ pub fn replace_space(s: String) -> String {
161
+ s.replace(' ', "%20")
162
+ }
163
+}
164
+```
165
166
+- 遍历添加
167
168
169
170
171
+ let mut result = String::new();
172
+ for c in s.chars() {
173
+ if c == ' ' {
174
+ result.push_str("%20");
175
+ } else {
176
+ result.push(c);
177
178
179
+ result
180
181
182
183
184
### **...**
185
186
lcof/面试题05. 替换空格/Solution.rs
@@ -0,0 +1,5 @@
1
2
3
4
5
0 commit comments