File tree 3 files changed +27
-1
lines changed
3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change
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
+
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ require github.com/stretchr/testify v1.7.0
6
6
7
7
require (
8
8
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
10
10
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
11
11
github.com/modern-go/reflect2 v1.0.2 // indirect
12
12
github.com/pmezard/go-difflib v1.0.0 // indirect
Original file line number Diff line number Diff line change 1
1
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8 =
2
2
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 =
3
4
github.com/davecgh/go-spew v1.1.1 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
4
5
github.com/google/gofuzz v1.0.0 /go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg =
5
6
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM =
You can’t perform that action at this time.
0 commit comments