User registration system

3.3

3 votes
Grammar-Verified, Grammar-Verified, Hash function, Hash Tables, Basic Programming, Data Structures, Hash table, Grammar-Verified, Easy
Problem

You are given a list of N users of a company and an empty database. Write a program to add names to the database based on the following conditions:

  • If a user’s name already exists in the database, print YES.
  • If a user's name does not exist in the database, add the user to the database and print NO.

Input format

  • First line: N
  • Next N lines: String S that denotes the username of a user and consists of lowercase English letters only

Output format

Print YES or NO for each string in a new line based on the result.

Constraints

1N105
1|S|32 where S denotes the length of the string

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

When the name "john" comes up the first time, we print "NO" because it does not exist in the database.

When it comes up the second time, we print "YES" because it exists in the database.

Editor Image

?