Merge branch 'master' of https://github.com/Omooo/Android-Notes
commit
de6c52d3b5
@ -0,0 +1,26 @@ |
||||
--- |
||||
字符串相关 |
||||
--- |
||||
|
||||
[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(); |
||||
} |
||||
} |
||||
``` |
||||
|
Loading…
Reference in new issue