problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
leetcode::hand_of_straights::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static bool isNStraightHand (vector< int > &hand, int groupSize)
 

详细描述

在文件 leetcode.h132 行定义.

成员函数说明

◆ isNStraightHand()

bool leetcode::hand_of_straights::Solution::isNStraightHand ( vector< int > &  hand,
int  groupSize 
)
static

在文件 leetcode.cpp192 行定义.

192 {
193 if(hand.size() % groupSize != 0) {
194 return false;
195 }
196 if(groupSize == 1) {
197 return true;
198 }
199 sort(hand.begin(), hand.end());
200 const auto len = hand.size() / groupSize;
201 for(int i = 0; i < len; i++) {
202 int current = *hand.begin();
203 hand.erase(hand.begin());
204 for(int j = 1; j < groupSize; j++) {
205 auto next = find(hand.begin(), hand.end(), current + 1);
206 if(next == hand.end()) {
207 return false;
208 }
209 current = *next;
210 hand.erase(next);
211 }
212 }
213 return true;
214 }
bool find(vector< unordered_set< int > > &g, int x, vector< bool > &st, vector< int > &match)
Definition: acwing.cpp:7522

引用了 acwing::acwing861::find().

被这些函数引用 leetcode::hand_of_straights::TEST().


该类的文档由以下文件生成: