Alien Party Invites
Mr. Little Z decided to throw a party for all the aliens he had met when he was on vacation to Mars. He finally decided who is he going to invite, and has to send invitations
Mr. Little Z found a list of all the aliens he has ever met, however the names in the list are in some random order, and the list contains some names multiple times. The list is actually written on a very very long piece of paper with every name in one line. Mr. Little Z wants to cut a part of the paper from the top, and a part from the bottom such that the remaining of the list contains the names of all the people he wants to invite and the list is as short as possible
Mathematical definition: you are given a list L1 that contains K different strings and a list L2 of N strings (that can repeat). You have to find a sub-list of L2 such that it contains every element from L1 at least once.
The list will always contain all the names of the aliens Mr. Little Z wants to invite to the party.
All the names consist of lowercase letters of the English alphabet with maximum 20 characters.
Examples:
Input:
3
admin
moderator
user
8
admin
moderator
hacker
programmer
user
coder
moderator
adminOutput:
4Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.