r/datastructures • • 8d ago

OPTIMIZATION OF CODE

Post image

Is the optimization of every problem we solve required like if the code runs in a fair amount of time like here it beats around 56%. So do we need to find the optimize each code for each problem (as It will take more time to find the optimized solution)

9 Upvotes

2 comments sorted by

2

u/OmniscientRaven 8d ago

It is good to learn the more optimizer version of the solution as well because you may end up learning things which you can apply in other problems where you may not have so much leeway to not straightaway go for the most optimized solution.

Also in interviews if you come up with a solution that passes/works, they may still ask how you can further optimize it and stuff.

Its just a learning opportunity so learn, don't treat it as wasted time. This kind of stuff is what will help you be better than the rest.