Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

1047. 删除字符串中的所有相邻重复项 #80

Open
Labels
@Geekhyt

Description

@Geekhyt

原题链接

  1. 扫描过的字符入栈暂存
  2. 如果扫描的当前字符与栈顶元素相同,则将栈顶元素出栈
  3. 将栈中剩余的字符转换成字符串
constremoveDuplicates=function(s){conststack=[]for(constiofs){if(stack.length&&stack[stack.length-1]===i){stack.pop()}else{stack.push(i)}}returnstack.join('')}
  • 时间复杂度: O(n)
  • 空间复杂度: O(n)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp