Close

## Number of ways to make coin change

Given some amount N, and a set of denominations, how do you find the number of ways to make change for N? Let us assume that there is infinite supply of coins for each denomination. For example, if we have to make change for 4, and the given denominations are {1, 2, 3}, the possibilities…

## Maximum Xor of two bit patterns

Given two numbers A, B, What is the maximum value of A’ XOR B’, where A’, B’ are obtained by permuting the binary representations of A, B respectively. For example assume A = 3, B = 1 and they are represented in 4 bits. A = 0011, B = 0001 in binary. Suppose A’ =…

## Finding the the number at a given position in even odd array

Given a number N, an array is created by first adding all the odd numbers, and then adding all the even numbers below N, How do we find the number at a given position K? For example consider N = 10, the array is [1, 3, 5, 7, 9, 2, 4, 6, 8, 10], the…

## Maximum increasing sub array

Given an array of numbers, how to find the maximum length of increasing (non-decreasing) continuous sub-sequence? For example consider the array [7, 9, 1, 3, 5, 8, 2], the maximum length is 4. Similarly for [23, 10, 18, 18, 6], it is 3. This is a straight forward implementation problem (appeared on Codeforces). Following is…

## Check if an array has a sub-array with given sum

Given an array of numbers and a sum, how to check if there is any sub-array with the given sum. For example consider an array A = [7, 2, 9, 1, 5], and the sum is 12, then we can find a sub-array [2, 9, 1] which sums up to 12. So the answer is…