## Longest Repeated Subsequence

The problem “Longest Repeated Subsequence” states that you are given a string as an input. Find out the longest repeated subsequence, that is the subsequence that exists twice in the string. Example   aeafbdfdg 3 (afd) Approach   The problem asks us to find out the longest repeated subsequence in the string. …

## Longest subsequence such that difference between adjacents is one

The problem “Longest subsequence such that difference between adjacents is one” states that you are given an integer array. Now you need to find the length of longest subsequence such that the difference of adjacent elements is 1. Example   1 2 3 4 7 5 9 4 6 Explanation As …

## Check if a given array contains duplicate elements within k distance from each other

The problem “Check if a given array contains duplicate elements within k distance from each other” states that we have to check for duplicates in given unordered array within the range of k. Here the value of k is smaller than the given array. Examples   K = 3   arr[] = …

## Pair with given product

The problem “Pair with given product” states that you are given an integer array and a number “x”. Determine, whether an array consists of a pair of which product equals ‘x’ exist in the given input array. Example   [2,30,12,5] x = 10 Yes, it has Product Pair Explanation Here 2 …

## Find a sorted subsequence of size 3 in linear time

Problem Statement   The problem “Find a sorted subsequence of size 3 in linear time” states that you have an integer array. The problem statement asks to find out the three numbers in such a way that array[i] < array [k] < array[k], and i < j < k. Example   arr[] …

## Rearrange array such that even index elements are smaller and odd index elements are greater

Problem Statement   You have given an array of integers. The problem “Rearrange array such that even index elements are smaller and odd index elements are greater” asks to rearrange the array in such a manner that the even index elements should be smaller than the odd index elements in a …

## Count pairs from two linked lists whose sum is equal to a given value

Problem Statement   Problem “Count pairs from two linked lists whose sum is equal to a given value” state that you are given two linked lists and an integer value sum. The problem statement asked to find out how many total pair has a sum equal to the given value. Example   …

## Printing brackets in Matrix Chain Multiplication Problem

Problem Statement   We need to find the order of multiplication of matrices such that the number of operations involved in the multiplication of all the matrices is minimized. Then we need to print this order i.e. printing brackets in matrix chain multiplication problem. Consider you have 3 matrices A, B, …

## Iterative Depth First Traversal of Graph

In iterative depth first traversal of graph problem, we have given a graph data structure. Write the program to print the depth first traversal of the given graph using the iterative method. Example   Input : 0 -> 1, 0 -> 2, 1 -> 2, 2 -> 0, 2 -> 3, 3 …

## Priority Queue

A priority queue is a type of data structure which is similar to a regular queue but has a priority associated with each of its element. Higher the priority earlier the element will be served. In some cases, there are two elements with the same priority then, the element enqueued …