Last weekend I was playing with Ruby in spoj when I had a doubt about optimizing a piece of code or not. I decided not optimizing. And then, after I got an AC, I uploaded the optimized version.
All I did was cache the answers, but the input for the tests maybe doesn’t repeat very often, if it does. This makes the “optimized” version almost 18% slower.
So, the lesson learned is: Premature optimization is the root of all evil.

0 comments ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment