MCPcopy Create free account
hub / github.com/Hsinha11/Leetcode-solutions / canConstruct

Method canConstruct

383-Ransom-Note/Ransom-Note.py:2–14  ·  view source on GitHub ↗
(self, ransomNote: str, magazine: str)

Source from the content-addressed store, hash-verified

1class Solution:
2 def canConstruct(self, ransomNote: str, magazine: str) -> bool:
3 c = 0
4
5 for char in ransomNote:
6 if char in magazine:
7 magazine = magazine.replace(char,"",1)
8 else:
9 c = c+1
10
11 if(c>0):
12 return False
13 else:
14 return True

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected