Editorial for Deck Distribution


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)

Code 1
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()))

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.