## Decrease and Conquer

As divide-and-conquer approach is already discussed, which include following steps: Divide the problem into a number of subproblems that are smaller instances of the same… Read More »

As divide-and-conquer approach is already discussed, which include following steps: Divide the problem into a number of subproblems that are smaller instances of the same… Read More »

Binary search is a popular method of searching in a sorted array or list. It simply divides the list into two halves and discard the… Read More »

Given an integer n, we need to find the number of positive integers whose factorial ends with n zeros. Examples: Input : n = 1… Read More »

Given two polynomials, A(x) and B(x), find the product C(x) = A(x)*B(x). In the previous post we discussed the recursive approach to solve this problem… Read More »

Given two polynomial A(x) and B(x), find the product C(x) = A(x)*B(x). There is already an O() naive approach to solve this problem. here. This… Read More »

We have to paint n boards of length {A1, A2, .. An}. There are k painters available and each takes 1 unit time to paint… Read More »

Given an array of sorted integers. We need to find the closest value to the given number. Array may contain duplicate values and negative numbers.… Read More »

Given a tank with capacity C liters which is completely filled in starting. Everyday tank is filled with l liters of water and in the… Read More »

Given an array of 2n elements in the following format { a1, a2, a3, a4, ….., an, b1, b2, b3, b4, …., bn }. The… Read More »

Given two sorted arrays. There is only 1 difference between the arrays. First array has one element extra added in between. Find the index of… Read More »

Convex hull is the smallest convex polygon containing all the given points. Input is an array of points specified by their x and y coordinates.… Read More »

Given two sorted arrays of size m and n respectively, you are tasked with finding the element that would be at the k’th position of… Read More »

Given many stacks of coins which are arranged adjacently. We need to collect all these coins in the minimum number of steps where in one… Read More »

An element is a peak element if it is greater than or equal to its four neighbors, left, right, top and bottom. For example neighbors… Read More »

Given a sorted matrix mat[n][m] and an element ‘x’. Find position of x in the matrix if it is present, else print -1. Matrix is… Read More »