+ 2
How to find complexity of my code
It finds the Nth maximum of a list , and also takes key as optional argument(ex, which is useful to find 3rd maximum odd number in a list) 1. What is time complexity of my code Can you improve it... https://code.sololearn.com/c4c3iZpb9bnJ/?ref=app
5 ответов
+ 2
You could either analyse your code manually here is detailed explanation of how to do so:
https://yourbasic.org/algorithms/time-complexity-explained/
Or you could make python calculate it for you, using library like big-O or Wily (but those are not standard and therefore doesn't work in sololearn)
+ 2
I'm not 100% sure to be honest, but Im quite sure time complexity of your max function is O(n^2 log(n))
Because there is a sort() method with time complexity of O(n log(n) ) nested inside a loop.
+ 2
Prabhas Koya , hmm
Seriously? That's why you posted this question? To get people check out your code? I mean common....
And this code is just a common max function so really it's not too useful... There are hundreds of thousands of such codes on the Internet...
I would rate the code about 5/10, mostly because its not very readable...
+ 2
Thanks
I asked for time complexity only,
and again thought of asking a legend(Aleksei Radchenkov ), about my code,by the way I am beginner
+ 2
My code is improved by Brian thanks to him