mirror of
https://github.com/CyC2018/Interview-Notebook.git
synced 2026-10-31 02:53:42 +00:00
Update 61. 扑克牌顺子.md
补充“解题思路”小节中通过排序、统计大小鬼数量来补齐空缺并判断顺子的文字说明。
This commit is contained in:
+2
-1
@@ -10,9 +10,10 @@
|
||||
|
||||
<div align="center"> <img src="pics/offer-poker-straight.png" width="560px"/> </div><br>
|
||||
|
||||
|
||||
## 解题思路
|
||||
|
||||
先排序,统计大小鬼(0)的个数 cnt。之后相邻的两张牌如果相同,就不可能组成顺子;不相同时,中间缺了 places[i + 1] - places[i] - 1 张牌,要用癞子补上。遍历完癞子还够用(cnt ≥ 0),就能组成顺子。
|
||||
|
||||
```java
|
||||
public boolean checkDynasty(int[] places) {
|
||||
if (places == null || places.length < 5)
|
||||
|
||||
Reference in New Issue
Block a user