We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0c72347 commit 709b710Copy full SHA for 709b710
ruby/0846-hand-of-straights.rb
@@ -0,0 +1,28 @@
1
+def is_n_straight_hand(hand, w)
2
+ hand = hand.sort()
3
+ index = 0
4
+ residual = []
5
+ cur = []
6
+ while(hand.length > 0)
7
+ num = hand.shift
8
+ if cur.size == 0
9
+ cur << num
10
+ else
11
+ if num == cur[-1] + 1
12
13
+ elsif num == cur[-1]
14
+ residual << num
15
+ elsif num > cur[-1] + 1
16
+ return false
17
+ end
18
19
+ if cur.length == w
20
+ hand = residual + hand
21
22
23
24
+
25
26
+ return (cur.size == 0 or cur.size == w)
27
28
+end
0 commit comments