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

[pull] master from youngyangyang04:master #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
pull merged 15 commits into AlgorithmAndLeetCode:master from youngyangyang04:master
Jun 6, 2022
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
9ac50a9
chore: Add new solution to LeetCode 203
tan-i-ham May 16, 2022
08147d1
添加 0232.用栈实现队列.md Scala版本
wzqwtt May 16, 2022
f4d98a7
添加 0225.用队列实现栈.md Scala版本
wzqwtt May 16, 2022
8df1b4b
Update 0739.每日温度.md
huangyebiaoke May 16, 2022
61f5d92
添加 0020.有效的括号.md Scala版本
wzqwtt May 16, 2022
98bdccb
添加 1047.删除字符串中的所有相邻重复项.md Scala版本
wzqwtt May 16, 2022
3493833
增加KMP php版本代码
fmtvar May 17, 2022
0281b82
增加php版本
fmtvar May 16, 2022
bdb357e
Merge pull request #1337 from tan-i-ham/master
youngyangyang04 Jun 6, 2022
17a818c
Merge pull request #1338 from wzqwtt/patch13
youngyangyang04 Jun 6, 2022
41eaab2
Merge branch 'master' into offer58-2
youngyangyang04 Jun 6, 2022
c53082e
Merge pull request #1339 from fmtvar/offer58-2
youngyangyang04 Jun 6, 2022
49a5d83
Merge pull request #1340 from huangyebiaoke/master
youngyangyang04 Jun 6, 2022
c054218
Merge pull request #1341 from wzqwtt/patch14
youngyangyang04 Jun 6, 2022
6d5cb71
Merge pull request #1342 from fmtvar/0028
youngyangyang04 Jun 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
添加 1047.删除字符串中的所有相邻重复项.md Scala版本
  • Loading branch information
wzqwtt committed May 16, 2022
commit 98bdccbe16bbb6c8c66e027d901f4fbd3baafffe
23 changes: 22 additions & 1 deletion problems/1047.删除字符串中的所有相邻重复项.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,27 @@ func removeDuplicates(_ s: String) -> String {
return String(stack)
}
```

Scala:
```scala
object Solution {
import scala.collection.mutable
def removeDuplicates(s: String): String = {
var stack = mutable.Stack[Int]()
var str = "" // 保存最终结果
for (i <- s.indices) {
var tmp = s(i)
// 如果栈非空并且栈顶元素等于当前字符,那么删掉栈顶和字符串最后一个元素
if (!stack.isEmpty && tmp == stack.head) {
str = str.take(str.length - 1)
stack.pop()
} else {
stack.push(tmp)
str += tmp
}
}
str
}
}
```
-----------------------
<div align="center"><img src=https://code-thinking.cdn.bcebos.com/pics/01二维码一.jpg width=500> </img></div>

AltStyle によって変換されたページ (->オリジナル) /