File tree 2 files changed +65
-0
lines changed
2 files changed +65
-0
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,41 @@ public:
142
142
143
143
```
144
144
145
+ ### ** Go**
146
+
147
+ ``` go
148
+ func isStraight (nums []int ) bool {
149
+ m := make (map [int ]struct {})
150
+ mi , ma := 14 , 0
151
+ for _ , num := range nums {
152
+ if num == 0 {
153
+ continue
154
+ }
155
+ if _ , exist := m[num]; exist {
156
+ return false
157
+ }
158
+ mi = min (mi, num)
159
+ ma = max (ma, num)
160
+ m[num] = struct {}{}
161
+ }
162
+ return ma-mi < 5
163
+ }
164
+
165
+ func max (x , y int ) int {
166
+ if x > y {
167
+ return x
168
+ }
169
+ return y
170
+ }
171
+
172
+ func min (x , y int ) int {
173
+ if x < y {
174
+ return x
175
+ }
176
+ return y
177
+ }
178
+ ```
179
+
145
180
### ** ...**
146
181
147
182
```
Original file line number Diff line number Diff line change
1
+ func isStraight (nums []int ) bool {
2
+ m := make (map [int ]struct {})
3
+ mi , ma := 14 , 0
4
+ for _ , num := range nums {
5
+ if num == 0 {
6
+ continue
7
+ }
8
+ if _ , exist := m [num ]; exist {
9
+ return false
10
+ }
11
+ mi = min (mi , num )
12
+ ma = max (ma , num )
13
+ m [num ] = struct {}{}
14
+ }
15
+ return ma - mi < 5
16
+ }
17
+
18
+ func max (x , y int ) int {
19
+ if x > y {
20
+ return x
21
+ }
22
+ return y
23
+ }
24
+
25
+ func min (x , y int ) int {
26
+ if x < y {
27
+ return x
28
+ }
29
+ return y
30
+ }
You can’t perform that action at this time.
0 commit comments