Hint: getting slices of the lists every time costs you a lot of time.
Also, please try describing your approach instead of posting the full code on the forum in the future.
Hint: getting slices of the lists every time costs you a lot of time.
Also, please try describing your approach instead of posting the full code on the forum in the future.
Hi, my code don’t work for three last tests but for the fourth even the if statement is false, the IDE is still going through it
if min(v, key=v.get) != 1:
print(some code)
else:
print(0)
print(v,min(v, key=v.get) != 5, file=sys.stderr, flush=True)
It print some code (a int that is not 0)
The debug command return this: {1: '3', 2: '4', 3: '7', 4: '9', 5: '10'} False
That’s because the values are strings. ‘10’ < ‘3’ is True (if those are integers instead of strings, then 10 > 3 is True).
Hi, my code work with all examples, but can’t validate the “Varied (1 5 4 10 8 4 5 42 41)”.
I tried to used it as a custom playtest and -4 as the result (8-4). Its work on the ide but when i submit it fail. Is the result -4 or i messed up in the process ?
The answer is -6 (10 → 8 → 4) instead of -4.
u can do it in time complexity O(n), with O(n**2) test 5 fails, unless you use a little trick that optimizes it, in which case even python will go through just fine. i recommend u find the best time complexity, thats the only real good answer and its not too hard to find(im missing run time from the site:/)
Solution 5 times out just from the auto-generated Dart code for parsing the standard input.
Adding the following line to the end of the code should remove the timeout for Dart:
exit(0);
For those like me that add a 0(N) program but didn’t past test 5.
My issue was that I left some debug comment in the program and that slowed it down, I didn’t know that those where taken into account