1
$\begingroup$

I have been watching some big (Google, Facebook,..) company interview examples and usually when pair programming, they develop the most straightforward algorithm and then the interviewer asks 'could you make it faster (reduce time complexity)'.

I have worked on optimizations of algorithms too and things that immediately spring to head when I optimize is to take out as many nested loops as possible, look for sorted data, change data structures, etc.

Since algorithm optimization is a common thing I was wondering is there a defined set of steps or principles on how to approach the reduction of time complexity of algorithms? something akin to SOLID for Object-oriented programming, but for reducing time complexity.

$\endgroup$
0
$\begingroup$

There are no defined easy steps you can follow. The principles you mentioned, like using efficient data structures or noticing patterns that can optimized are often the basis for optimizing algorithms, but the number of different techniques is large. Most of the techniques used in interview questions can be found in basic algorithms textbooks like Introduction to Algorithms.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.