Skip to content

Commit a0d7284

Browse files
committedApr 4, 2024·
feat: 2810
1 parent cfae1a9 commit a0d7284

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed
 
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// 時間複雜度:
2+
// 空間複雜度:
3+
/*
4+
* @lc app=leetcode.cn id=2810 lang=golang
5+
*
6+
* [2810] 故障键盘
7+
*/
8+
9+
// @lc code=start
10+
func finalString(s string) string {
11+
queue := [2][]rune{} // 0:向左, 1:向右
12+
dir := 1
13+
for _, c := range s {
14+
if c == 'i' {
15+
dir ^= 1
16+
} else {
17+
queue[dir] = append(queue[dir], c)
18+
}
19+
}
20+
slices.Reverse(queue[dir^1])
21+
return string(append(queue[dir^1], queue[dir]...))
22+
}
23+
24+
// @lc code=end
25+

‎go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require github.com/stretchr/testify v1.7.0
66

77
require (
88
github.com/davecgh/go-spew v1.1.1 // indirect
9-
github.com/json-iterator/go v1.1.12 // indirect
9+
github.com/json-iterator/go v1.1.12
1010
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
1111
github.com/modern-go/reflect2 v1.0.2 // indirect
1212
github.com/pmezard/go-difflib v1.0.0 // indirect

‎go.sum

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
22
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
34
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
45
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
56
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=

0 commit comments

Comments
 (0)
Please sign in to comment.