HR_Hash Tables: Ransom Note

Posted alfredsun

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HR_Hash Tables: Ransom Note相关的知识,希望对你有一定的参考价值。

1 题目重点:whole words | case-sensitive

#!/bin/python3

import math
import os
import random
import re
import sys

# Complete the checkMagazine function below.
def checkMagazine(magazine, note):
    # m_len magazine  n_len note
    m_len = len(magazine)
    n_len = len(note)
    # magazine = sorted(magazine)
    # note = sorted(note)
    for i in range(n):
        try:
            temp = magazine.index(note[i])
            magazine[temp] = 0
        except ValueError:
            return No
    return Yes

if __name__ == __main__:
    mn = input().split()

    m = int(mn[0])

    n = int(mn[1])

    magazine = input().rstrip().split()

    note = input().rstrip().split()

    print(checkMagazine(magazine, note)) 
     

 

以上是关于HR_Hash Tables: Ransom Note的主要内容,如果未能解决你的问题,请参考以下文章

LeetCode 383. Ransom Note

LeetCode(383)Ransom Note

LeetCode 383 Ransom Note

LeetCode 383 Ransom Note

LeetCode:Ransom Note_383

[LeetCode]383. Ransom Note 解题小结