Close

## Maximum number of contiguous ones with K zeros

Given an array of size N, containing only 0’s and 1’s, and a number K, what is the maximum length of the sub-array with contiguous 1’s with at most K 0’s? For example consider the array A = [1, 1, 0, 1, 0, 0, 1], K = 2, the maximum length is 5. i.e the…

## Stamps problem – SPOJ

This problem is from SPOJ. Give it a try by following this link! The simplified problem statement is as follows.  You need to collect some stamps from friends. Suppose you have n friends and each of them have some stamps with them {s1, s2, … sn}.   The problem is to find if we can…

## Boys and Girls – SPOJ problem

This problem is from SPOJ. Please follow this link if you want to try on your own! The problem is as follows. Given some number of boys and girls, we have to arrange them in a row such that the same gender appear together is minimized.  We have to find the minimum number of any…

## Problem of candies: SPOJ

This problem is from SPOJ (Sphere Online Judge – A site to practice your problem solving skills). If you want to solve this problem on your own, please follow the link.The simplified problem description is as follows.  A teacher has n packets of candies of varying sizes. The problem is to find the number of…