Binary search is an awfully underrated algorithm. The way it’s usually introduced in a classroom is to show how it can be used to find an element in a sorted array. Although this exercise shows the general gist behind binary search, it hides the truly beautiful idea behind the algorithm. In this article, I wish to attempt to explain it so that you can know when you could use a binary search, even in the most unusual situations.

So, uh, what is binary search?

Just so we are all on the same page, here’s a quick refresher on binary search. Consider an array of sorted elements.


In this blog, we will look at how you could approach the problem “Santa gives gifts” in The Coding Culture’s December Contest “Number Quest”.

Mathematics behind the problem

This problem, in the end, boils down to being able to count without overcounting, Let’s see what I mean by this

Say you want to find number of numbers that are divisible by 5 from 1 to 50; well, clearly anyone would say its 10, right? well, all you did was divide 50 by 5 right. …


In this blog, we will look at how you could approach the problem “Kids at home” in The Coding Culture’s November Contest “Get Set and Code”.

Understanding the problem statement

The statement reads as follows:

k kids seem to have visited your home for the festival. It seems like the kids had all been fighting with each other, so you decided to keep them as far as possible from each other. You had placed n chairs on the positive number line, each at position xi , 1 ≤ i ≤ n. You can make the kids sit in any of the chairs. …


In this blog, we will look at how you could approach the problem “Find Minimum” in The Coding Culture’s November Contest “Get Set and Code”.

The problem statement goes like so:

Yash likes playing with numbers. He has a challenge for you. Yash gives you a number that he made by multiplying two numbers. He claims that the possible sum of the two numbers he multiplied is as minimum as possible. He challenges you to find that minimum sum. …

Alaap Surendran

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store