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.
No, key=int doesn't suffice. Parsing an integer from a string is a very heavyweight operation. Performing it unnecessarily will cause the python program to time out.
We need to use lightweight comparison functions first, and only use the heavyweight ones if there's no alternative.
My Python solution, to which I arrived independently, turns out to be very similar to this one, for the reasons mentioned.
Big Sorting
You are viewing a single comment's thread. Return to all comments →
No, key=int doesn't suffice. Parsing an integer from a string is a very heavyweight operation. Performing it unnecessarily will cause the python program to time out. We need to use lightweight comparison functions first, and only use the heavyweight ones if there's no alternative. My Python solution, to which I arrived independently, turns out to be very similar to this one, for the reasons mentioned.