You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
521 B
27 lines
521 B
5 years ago
|
---
|
||
|
字符串相关
|
||
|
---
|
||
|
|
||
|
[05. 替换空格](https://leetcode-cn.com/problems/ti-huan-kong-ge-lcof/)
|
||
|
|
||
|
```java
|
||
|
class Solution {
|
||
|
|
||
|
public String replaceSpace(String s) {
|
||
|
StringBuilder builder = new StringBuilder();
|
||
|
int i = 0;
|
||
|
while (i < s.length()) {
|
||
|
char c = s.charAt(i);
|
||
|
if (c == ' ') {
|
||
|
builder.append("%20");
|
||
|
} else {
|
||
|
builder.append(c);
|
||
|
}
|
||
|
i++;
|
||
|
}
|
||
|
return builder.toString();
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|