ransomNote construction

  • 0

    Given a list of words in newpaper which may contains duplicates, write a a function as follows to evaluate if the words in ransom note can be constructed from the newspaper.

    boolean CanDoRansom(List<string> ransomNote, List<string> newspaper)

    Company: Apple

  • 0

    Could you add a company tag, please? Would it be possible for you to provide an example? Thank you

  • 0
    def canDoRansom(string, newspaper):
      for i in string:
        count = string.count(i)
        if i in newspaper:
          count_i = newspaper.count(i)
          if count > count_i:
            return "False"
          return "False"
      return "True"

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.