mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 19:44:45 +08:00
1047.Java第二种解法,可以优化成速度更快的
This commit is contained in:
@ -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>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user