Leetcode #383 Ransom Note
Given two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine and false otherwise.
Each letter in magazine can only be used once in ransomNote.
Example 1:
Input: ransomNote = "a", magazine = "b"
Output: false
Example 2:
Input: ransomNote = "aa", magazine = "ab"
Output: false
Example 3:
Input: ransomNote = "aa", magazine = "aab"
Output: true
Constraints:
We can Solve this easily with an hash map in python:
We all know that Counter(array) in Python gives a hash map with the key and value as the count of that particular key.
Follow these steps:
ServiceNow Developer @RSC Solution | ServiceNow Developer/Full Stack Developer | Project Manager | React.js | Python | SQL | Mongo DB | Master’s in Computer Science
1yAmazing idea to solve RansomeNote problem using python. Keep it up Prathima Seethalam Radhakrishna . 👍