File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Leetcode-May-Challenge/Day - 3 Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 1+ ##==================================
2+ ## Leetcode May Challenge
3+ ## Username: Vanditg
4+ ## Year: 2020
5+ ## Problem: 3
6+ ## Problem Name: Ransom Note
7+ ##===================================
8+ #
9+ #Given an arbitrary ransom note string and another string containing letters from all the magazines,
10+ #write a function that will return true if the ransom note can be constructed from the magazines ; otherwise, it will return false.
11+ #
12+ #Each letter in the magazine string can only be used once in your ransom note.
13+ #
14+ #Note:
15+ #You may assume that both strings contain only lowercase letters.
16+ #
17+ #canConstruct("a", "b") -> false
18+ #canConstruct("aa", "ab") -> false
19+ #canConstruct("aa", "aab") -> true
20+ from collections import Counter as c #Importing Counter module
21+ class Solution :
22+ def canConstruct (self , ransomNote , magazine ):
23+ return not c (ransomNote ) - c (magazine ) #Return True if ransom note constructed from magazine otherwise false
You can’t perform that action at this time.
0 commit comments