Damn I see. I thought my solution was really bad compared to this one, but I didn't consider performance as things scale up.
Agreed, it has O(n^2) complexity but can be done in O(n)
I completely agree with you. Unfortunately, when it comes to python, "best practice" seems to be shortest answer regardless of optimisation. Keep flagging these.
This comment is hidden because it contains spoiler information about the solution
I kept getting timeout and I even tested using the best solution and the error persists.
What is the Big-O notation of your solution? As long as you do it in O(n) or O(n**2), it should pass the tests.
O(n)
O(n**2)
Loading collection data...
Damn I see. I thought my solution was really bad compared to this one, but I didn't consider performance as things scale up.
Agreed, it has O(n^2) complexity but can be done in O(n)
I completely agree with you. Unfortunately, when it comes to python, "best practice" seems to be shortest answer regardless of optimisation. Keep flagging these.
This comment is hidden because it contains spoiler information about the solution
What is the Big-O notation of your solution? As long as you do it in
O(n)
orO(n**2)
, it should pass the tests.This comment is hidden because it contains spoiler information about the solution