Editorial for Deck Distribution
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Approach
A complete deck has 52 distinct card strings. Since the input always contains exactly 52 lines, we only need to check whether any card appears more than once.
Store all 52 strings in a list, convert that list to a set, and compare lengths:
- If
len(set(cards)) == 52, every card is unique, so printYES. - Otherwise, at least one duplicate exists, so print
NO.
Time complexity is O(52), which is effectively constant.
Solution (Python)
def solve(l):
return "YES" if len(set(l)) == len(l) else "NO"
def parse():
temp = []
for i in range(52):
temp.append(input())
return temp
print(solve(parse()))
Comments