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.

Author: kahootist

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 print YES.
  • 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

There are no comments at the moment.