Skip to content

Latest commit

 

History

History
37 lines (30 loc) · 1.57 KB

File metadata and controls

37 lines (30 loc) · 1.57 KB
  • Harold is a kidnapper who wrote a ransom note, but now he is worried it will be traced back to him through his handwriting. He found a magazine and wants to know if he can cut out whole words from it and use them to create an untraceable replica of his ransom note. The words in his note are case-sensitive and he must use only whole words available in the magazine. He cannot use substrings or concatenation to create the words he needs.

  • Given the words in the magazine and the words in the ransom note, print Yes if he can replicate his ransom note exactly using whole words from the magazine; otherwise, print No.

  • For example, the note is "Attack at dawn". The magazine contains only "attack at dawn". The magazine has all the right words, but there's a case mismatch. The answer is No.

  • It must print Yes if the note can be formed using the magazine, or No.

  • Instance format:

    • The first line contains two space-separated integers m and n, the numbers of words in the magazine and the note.
    • The second line contains m space-separated strings, each magazine[i]
    • The third line contains n space-separated strings, each note[i]
  • Input:

        6 4
        give me one grand today night
        give one grand today
  • Output:
        Yes

Running

  • Running an instance:
    python main.py "path_instance"
  • Example: running an instance "input1":
    python main.py instances/input1