I'm trying to solve a coding problem for Hackerrank but continuously run into timeout errors for my code taking too long to run. I know that it works perfectly fine, indentation is not the problem, there is nothing 'wrong' with the code at all. I just need tips on how I can make it run more efficiently:
def main(n, o, q, m):
for x in m:
for y,z in enumerate(o):
x -= z
if x<=0:
print y+1
break
if x>0: print -1
o and m are a list of integers that are looped through subtracting the values of o from m until m is less than 0, the loop finishes and m is still not less than 0 it will print -1. The ultimate goal is to find which int from o finishes m.