You are given an empty dictionary and
queries. Each query can be one of the following two types:
- Type 1: Insert a string into the dictionary.
- Type 2: Check if a string exists in the dictionary.
Your task is to implement a program that processes these queries efficiently.
For a query of type 2 if the string is present, output
Yes, otherwise, output
The input consists of multiple lines. The first line contains an integer,
(1 ≤ ≤ ), representing the number of queries.
The following lines describe the queries. Each line starts with an integer, type (1 or 2), indicating the type of query.
- If type = 1, the line will be followed by a space and a string s (1 ≤ |s| ≤ 1000), representing the string to be inserted into the dictionary. The string consists of lowercase English letters only.
- If type = 2, the line will be followed by a space and a string s (1 ≤ |s| ≤ 1000), representing the string to be checked in the dictionary. The string consists of lowercase English letters only.
It is guaranteed that the sum of the lengths of all query strings does not exceed .
For each query of type 2, output "Yes" if the string is present in the dictionary, otherwise, output "No".
5 1 abc 1 xyz 2 cba 1 def 2 xyz
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB