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.
You can run in linear time without ugliness. Google and Facebook value maintainable code and have extensive coding standards devoted to that.
Start with the clean code, move to the fast code as necessary. The result will still look better than that.
The Hackerrank challenges actually offer good training in this approach. Start with the clean solution, then see which tests - if any - it fails, then see how much you have to contort the code to make it meet the challenge. Aim for the least distortion necessary, because the clean code is easier to maintain. Which will oten matter even in these challenges, when your optimisation clears one difficult test but still fails the next.
There's never an excuse for starting with something that much of a mess.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Nested Lists
You are viewing a single comment's thread. Return to all comments →
You can run in linear time without ugliness. Google and Facebook value maintainable code and have extensive coding standards devoted to that.
Start with the clean code, move to the fast code as necessary. The result will still look better than that.
The Hackerrank challenges actually offer good training in this approach. Start with the clean solution, then see which tests - if any - it fails, then see how much you have to contort the code to make it meet the challenge. Aim for the least distortion necessary, because the clean code is easier to maintain. Which will oten matter even in these challenges, when your optimisation clears one difficult test but still fails the next.
There's never an excuse for starting with something that much of a mess.