aboutsummaryrefslogtreecommitdiff
path: root/other/hand_of_straights.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'other/hand_of_straights.cpp')
-rw-r--r--other/hand_of_straights.cpp30
1 files changed, 0 insertions, 30 deletions
diff --git a/other/hand_of_straights.cpp b/other/hand_of_straights.cpp
deleted file mode 100644
index b08c7fa..0000000
--- a/other/hand_of_straights.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-#include "leetcode.h"
-
-class Solution {
-public:
- bool isNStraightHand(vector<int> &hand, int groupSize) {
- if (hand.size() % groupSize != 0)
- return false;
- map<int, int> m;
- for (auto &card : hand)
- m[card]++;
- for (int i = 0; i < groupSize; i++) {
- int curr = m.begin()->first;
- if (m[curr + i] == 0)
- return false;
- else if (--m[curr + i] < 1)
- m.erase(curr + i);
- }
- return true;
- }
-};
-
-int main() {
- Solution obj;
- vector<int> hand = {1, 2, 3, 6, 2, 3, 4, 7, 8};
- int groupSize = 3;
- if (obj.isNStraightHand(hand, groupSize))
- cout << "true";
- else
- cout << "false";
-}