Created
September 10, 2019 02:46
-
-
Save atul-chaudhary/072fcc6d7f6478fc0b2a75665587c0aa to your computer and use it in GitHub Desktop.
leetcode 914: X of a Kind in a Deck of Cards
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def hasGroupsSizeX(self, deck) -> bool: | |
d = {} | |
for i in range(len(deck)): | |
if (deck[i] in d): | |
d[deck[i]] += 1 | |
else: | |
d[deck[i]] = 1 | |
print(d) | |
for x in range(2, len(deck) + 1): | |
if (len(deck) % x == 0): | |
if all(v%x==0 for v in d.values()): | |
return True | |
else: | |
return False | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment