Close

## Billing algorithm

This problem is from Codechef. I am re-wording it for more clarity. A garments shop has “Buy 2, Get 2” offer for it’s customers. Whatever the items may be, they charge for costliest items from an order and give the cheapest ones free. However we can divide the items into multiple orders to save more.…

## Minimum number of jumps to reach top

There are N steps in a staircase, and a person can jump 5 steps at max, i.e he can jump any number of steps between 1 and 5. What is the minumum number of jumps he has to make to reach the top? A simple math problem which can be solved using a simple greedy…

## Standing Ovation: Google codejam 2015 Qualification round problem

Every year Google conducts a competition called Codejam for programming enthusiasts. The qualification round for the year 2015 got finished yesterday. In this post, I am going to explain the solution approach for the first problem.You can read the problem from this link. I will try to give the abridged problem statement below. There are…

## Minimum number after removing K digits

Given a number N, and a number K, find the minimum number that can be formed by deleting K digits. The order of the digits should not be changed. For example consider N = 234987, K = 2, we can remove 9,8 and the resulting number is 2347.The solution is based on the following observation,…