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.
My code read everything in one go then just returns and every function or method is called only once (total of 7 function calls).
Your code on the other hand has 12 function calls and calls max() for every element in the list. Also, according to PEP, variable names should start with lowercase, so N should be n.
I suppose I could use map to change list elements to int, but in this case list comprehension is almost as fast.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Find the Runner-Up Score!
You are viewing a single comment's thread. Return to all comments →
I think "pythonic" is an overused word :) Anyways I did a profile on those two implementations:
My code read everything in one go then just returns and every function or method is called only once (total of 7 function calls).
Your code on the other hand has 12 function calls and calls max() for every element in the list. Also, according to PEP, variable names should start with lowercase, so N should be n.
I suppose I could use map to change list elements to int, but in this case list comprehension is almost as fast.