You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classSolution {
public:boolisStraight(vector<int>& nums) {
unordered_set<int> repeat;
int ma = -1, mi = INT_MAX;
for (auto n: nums) {
if (n != 0) {
if (n > ma)
ma = n;
if (n < mi)
mi = n;
if (repeat.count(n) != 0)
returnfalse;
else
repeat.insert(n);
}
}
if (ma - mi < 5)
returntrue;
returnfalse;
}
};
The text was updated successfully, but these errors were encountered:
从扑克牌中随机抽5张牌,判断是不是一个顺子,即这5张牌是不是连续的。2~10为数字本身,A为1,J为11,Q为12,K为13,而大、小王为 0 ,可以看成任意数字。A 不能视为 14。
示例 1:
示例 2:
限制:
解法:
顺子的充分必要条件是:
代码如下:
The text was updated successfully, but these errors were encountered: