File tree 2 files changed +42
-0
lines changed
2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -228,6 +228,30 @@ public class Solution {
228
228
}
229
229
```
230
230
231
+ #### Swift
232
+
233
+ ``` swift
234
+ class Solution {
235
+ func isStraight (_ nums : [Int ]) -> Bool {
236
+ var vis = Array (repeating : false , count : 14 )
237
+ var mi = 20 , mx = -1
238
+ for x in nums {
239
+ if x == 0 {
240
+ continue
241
+ }
242
+ if vis[x] {
243
+ return false
244
+ }
245
+ vis[x] = true
246
+ mi = min (mi, x)
247
+ mx = max (mx, x)
248
+ }
249
+ return mx - mi <= 4
250
+ }
251
+ }
252
+
253
+ ```
254
+
231
255
<!-- tabs: end -->
232
256
233
257
<!-- solution: end -->
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ func isStraight( _ nums: [ Int ] ) -> Bool {
3
+ var vis = Array ( repeating: false , count: 14 )
4
+ var mi = 20 , mx = - 1
5
+ for x in nums {
6
+ if x == 0 {
7
+ continue
8
+ }
9
+ if vis [ x] {
10
+ return false
11
+ }
12
+ vis [ x] = true
13
+ mi = min ( mi, x)
14
+ mx = max ( mx, x)
15
+ }
16
+ return mx - mi <= 4
17
+ }
18
+ }
You can’t perform that action at this time.
0 commit comments