We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Hey buddy, Where do you think i am messing around here? Its failing few test cases.
Complete the checkMagazine function below.
def checkMagazine(magazine, note):
_magList = magazine
_matchedList = []
for i in note:
if i in _magList:
_magList.remove(i)
_matchedList.append(i)
if _matchedList == note:
print('Yes')
else:
print('No')
def checkStrings(a):
_retCode = True
_cnt = 0
for i in a:
_cnt = _cnt +1
if not i.isalpha():
_retCode = False
if _cnt == 0 or _cnt > 30000:
_retCode = False
return _retCode
if name == 'main':
mn = input().split()
m = int(mn[0])
n = int(mn[1])
magazine = input().rstrip().split()
note = input().rstrip().split()
if 1 <= m <=30000 and 1 <= n <=30000:
if checkStrings(magazine) and checkStrings(note):
checkMagazine(magazine, note)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Hash Tables: Ransom Note
You are viewing a single comment's thread. Return to all comments →
Hey buddy, Where do you think i am messing around here? Its failing few test cases.
Complete the checkMagazine function below.
def checkMagazine(magazine, note): _magList = magazine _matchedList = [] for i in note: if i in _magList: _magList.remove(i) _matchedList.append(i) if _matchedList == note: print('Yes') else: print('No') def checkStrings(a): _retCode = True _cnt = 0 for i in a: _cnt = _cnt +1 if not i.isalpha(): _retCode = False if _cnt == 0 or _cnt > 30000: _retCode = False return _retCode
if name == 'main': mn = input().split()