Did you know that you can navigate the posts by swiping left and right?
in this blog post, i hope to highlight one of the most common algorithm patterns i compiled while prepping for my coding interviews. when i first started prepping for coding interviews, i tended to memorize the solutions for coding problems in the hopes that my interviewer would ask exactly the questions i studied. as you can guess, that never really happened so instead, i started to learn the patterns that are hidden in these problems so i could learn how to approach new problems – problems i’ve never seen before!
i think it is so important, as a programmer, to look at what the inputs of the problem are. it gives you insight on how to break the question down. for inputs that are sorted lists, it is almost always safe to assume that you will be using binary search in some form. modified binary searches are such a popular coding interview question, and it is important to first, understand what binary search does, and how you can modify it to fit your problem. binary search essentially splits our sorted list into half with each iteration, also reducing our search space by half. this does wonders for reducing the linear search runtime to a logarithmic search runtime.
binary search algorithm:
modified binary search problems: