## Minimum steps to reach any of the boundary edges of a matrix | Set 1

Given an N X M matrix, where ai, j = 1 denotes the cell is not empty, ai, j = 0 denotes the cell is… Read More »

## Count columns to be deleted to make each row sorted

Given an array arr[] of strings of same length, the task is to count the number of columns to be deleted so that all the… Read More »

## Count the number of special permutations

Given two positive integers n and k, the task is to count the number of special permutations. A special permutation P is defined as a… Read More »

## Number of Binary Strings of length N with K adjacent Set Bits

Given and . The task is to find the number of binary strings of length n out of 2n such that they satisfy f(bit string)… Read More »

## Number of Paths of Weight W in a K-ary tree

Given a K-ary tree, where each node is having K children and each edge has some weight. All the edges i.e. K, that goes from… Read More »

## Number of balanced bracket expressions that can be formed from a string

Given a string str comprising of characters (, ), {, }, [, ] and ?. The task is to find the total number of balanced… Read More »

## Count pairs (A, B) such that A has X and B has Y number of set bits and A+B = C

Given two numbers x, y which denotes the number of set bits. Also given is a number C. The task is to print the number… Read More »

## Paths with maximum number of ‘a’ from (1, 1) to (X, Y) vertically or horizontally

Given a N X N matrix consisting of characters. Also given are Q queries, where each query contains a co-ordinate (X, Y). For every query,… Read More »

## Ways to place K bishops on an N×N chessboard so that no two attack

Given two integers N and K, the task is to find the number of ways to place K bishops on an N × N chessboard… Read More »

## Find the sum of first N odd Fibonacci numbers

Given a number, N. find the sum of first N odd Fibonacci numbers. Note: The answer can be very large so print the answer modulo… Read More »

## Number of ways to partition a string into two balanced subsequences

Given a string ‘S’ consisting of open and closed brackets, the task is find the number of ways in which each character of ‘S’ can… Read More »

## Minimum cost to reach a point N from 0 with two different operations allowed

Given integers N, P and Q where N denotes the destination position. The task is to move from position 0 to position N with minimum… Read More »

## Treasure and Cities

Given n cities: x1, x2, …… xn: each associated with T[i] (treasure) and C[i] (color). You can choose to visit a city or skip it.… Read More »

## Memoization using decorators in Python

Recursion is a programming technique where a function calls itself repeatedly till a termination condition is met. Some of the examples where recursion is used… Read More »

## Count ways to reach a score using 1 and 2 with no consecutive 2s

A cricket player has to score N runs, with condition he can take either 1 or 2 runs only and consecutive runs should not be… Read More »