Close

## 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,…

## Maximum nesting depth of a paranthesis expression

Given a parenthesis expression, We have to find the maximum nesting depth. For example: the expression ()((()))(()) has a maximum nesting depth of 3. The expression ((()())) has a maximum nesting depth of 3. Let us output -1 for an unbalanced expressions such as (())) or ()( This is a simple problem that can be…

## Minimum number of chages to make equal groups

Given an array of numbers, how do we find the minimum number of changes(additions/subtractions) to the elements so that each number in the array is same or equal. For example given the array {1, 2, 3, 4}, the minimum number of changes are 3. i.e we can choose any of the four elements and make…

## Minimum number of symbols to change to make a chain

Given a string containing the only symbols ‘+’ or ‘-‘, how do we find the minimum number of changes to transform it to a chain. A chain of length N is the sequence of alternative + and – symbols. For example “+-+-+” is a chain of length 5. Similarly “-+-+-+” is a chain of length…

## Next greater number with same digits

Given a number, how do we find the next greater number with the same digits?   For example if the given number is 123, the next greater number with the same digits is 132. Similarly for 23876, the output is 26378. If all the digits of the number are in decreasing order (Eg. 54321), there…

## Inverse permutation problem

This problem is from code forces. If you want to try this problem, follow this link. Here is the simplified problem statement. Given a group of N friends, each one has given a gift to other friend or themselves. An input array is given which indicates from whom each one has received their gifts. We…

## Minimum AND of all subsets

This problem is from a recent contest on Hackerrank. If you want to solve this problem on your own, Click on this link.Here is the problem statement:Given array of size N, we have to find all the subsets of size > 2 of this array. Apply AND (bitwise &) on all the subsets. Print the…