Interviewers usually expect efficient solutions that solve problems within the resource constraints, so it is important for candidates to improve code performance from the perspectives of both time and space consumption. This chapter illustrates strategies to optimize programs by selecting appropriate data structures and algorithms, as well as by making trade-off decisions to balance time and space efficiencies.

Time Efficiency

No one likes to wait for a delayed response from a software application, so companies spend a lot of resources on performance optimization before software releases. That is why many interviewers ...

Get Coding Interviews: Questions, Analysis & Solutions now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.