We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 87fbe5d commit ff8583dCopy full SHA for ff8583d
lcp/LCP 17. 速算机器人/README.md
@@ -118,6 +118,25 @@ func calculate(s string) int {
118
}
119
```
120
121
+#### Swift
122
+
123
+```swift
124
+class Solution {
125
+ func calculate(_ s: String) -> Int {
126
+ var x = 1
127
+ var y = 0
128
+ for c in s {
129
+ if c == "A" {
130
+ x = x * 2 + y
131
+ } else if c == "B" {
132
+ y = y * 2 + x
133
+ }
134
135
+ return x + y
136
137
+}
138
+```
139
140
<!-- tabs:end -->
141
142
<!-- solution:end -->
lcp/LCP 17. 速算机器人/Solution.swift
@@ -0,0 +1,14 @@
1
2
3
4
5
6
7
8
9
10
11
12
13
14
0 commit comments