1047.Java第二种解法,可以优化成速度更快的
This commit is contained in:
parent
d9ef071119
commit
781b38d3fa
|
|
@ -153,6 +153,8 @@ class Solution {
|
||||||
class Solution {
|
class Solution {
|
||||||
public String removeDuplicates(String s) {
|
public String removeDuplicates(String s) {
|
||||||
// 将 res 当做栈
|
// 将 res 当做栈
|
||||||
|
// 也可以用 StringBuilder 来修改字符串,速度更快
|
||||||
|
// StringBuilder res = new StringBuilder();
|
||||||
StringBuffer res = new StringBuffer();
|
StringBuffer res = new StringBuffer();
|
||||||
// top为 res 的长度
|
// top为 res 的长度
|
||||||
int top = -1;
|
int top = -1;
|
||||||
|
|
@ -470,3 +472,4 @@ impl Solution {
|
||||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||||
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
|
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue