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.
I am writing to ask for a favour. My function passes the first 36 tests. However, the tests from 38 to 44 show that my function exceeds time limit. I wonder whether anyone can help me with it. Thank you for your time.
defnoPrefix(words):# Write your code heren=len(words)length=[itemforiteminrange(0,n,1)]length[0]=len(words[0])foriinrange(1,n,1):length[i]=len(words[i])forjinrange(0,i,1):a=min(length[i],length[j])ifwords[i][0:a]==words[j][0:a]:print("BAD SET")print(words[i])returnprint("GOOD SET")
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
No Prefix Set
You are viewing a single comment's thread. Return to all comments →
running time exceeds limits
I am writing to ask for a favour. My function passes the first 36 tests. However, the tests from 38 to 44 show that my function exceeds time limit. I wonder whether anyone can help me with it. Thank you for your time.