# What is the time complexity problem I need to manage on a Hackerank “Ransom Note” - my code runs perfectly [closed]

I am trying to solve the "Ransom Note" problem on hackerank. Why isn't my code getting submitted? What can I do differently? is my total time complexity, in this case, it is O(n^2)?

#!/bin/python3

import math
import os
import random
import re
import sys

# Complete the checkMagazine function below.
def checkMagazine(magazine, note):

for word in note:                                         # O(n)
if word not in magazine:                              # O(n)
return 'No'
else:
magazine.remove(word)                             # O(n)

return 'Yes'

if __name__ == '__main__':
mn = input().split()

m = int(mn[0])

n = int(mn[1])

magazine = input().rstrip().split()

note = input().rstrip().split()

print(checkMagazine(magazine, note))

• "Why isn't my code getting submitted?" - I guess because you're not submitting it? – superb rain Sep 11 '20 at 17:24
• And if you do submit it, it doesn't get accepted. Probably that's what you meant? Then you know that it's not correct, making this off-topic here. – superb rain Sep 11 '20 at 17:33
• In your assessment of asymptotic bounds of complexity, you need more variables to model problem size. – greybeard Sep 13 '20 at 15:27
• (You may try and find an approach minimising memory required.) – greybeard Sep 13 '20 at 15:29