Update 61. 扑克牌顺子.md

题目链接改为力扣中的对应题目,题目描述和代码按该题的接口调整。
This commit is contained in:
CyC2018
2026-10-28 13:45:07 +08:00
parent e68818f002
commit 23d21cdfd4
+9 -10
View File
@@ -2,7 +2,7 @@
## 题目链接
[NowCoder](https://www.nowcoder.com/practice/762836f4d43d43ca9deb273b3de8e1f4?tpId=13&tqId=11198&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
[Leetcode](https://leetcode.cn/problems/bu-ke-pai-zhong-de-shun-zi-lcof/)
## 题目描述
@@ -14,24 +14,23 @@
## 解题思路
```java
public boolean isContinuous(int[] nums) {
if (nums.length < 5)
public boolean checkDynasty(int[] places) {
if (places == null || places.length < 5)
return false;
Arrays.sort(nums);
Arrays.sort(places);
// 统计癞子数量
int cnt = 0;
for (int num : nums)
if (num == 0)
for (int place : places)
if (place == 0)
cnt++;
// 使用癞子去补全不连续的顺子
for (int i = cnt; i < nums.length - 1; i++) {
if (nums[i + 1] == nums[i])
for (int i = cnt; i < places.length - 1; i++) {
if (places[i + 1] == places[i])
return false;
cnt -= nums[i + 1] - nums[i] - 1;
cnt -= places[i + 1] - places[i] - 1;
}
return cnt >= 0;