1047.Java第二种解法,可以优化成速度更快的

This commit is contained in:
hbingzhi
2022-12-03 14:46:28 +08:00
parent d9ef071119
commit 781b38d3fa

View File

@ -153,6 +153,8 @@ class Solution {
class Solution {
public String removeDuplicates(String s) {
// 将 res 当做栈
// 也可以用 StringBuilder 来修改字符串,速度更快
// StringBuilder res = new StringBuilder();
StringBuffer res = new StringBuffer();
// top为 res 的长度
int top = -1;
@ -470,3 +472,4 @@ impl Solution {
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>