## Cutting a Rod | DP-13

Given a rod of length n inches and an array of prices that contains prices of all pieces of size smaller than n. Determine the… Read More »

Given a rod of length n inches and an array of prices that contains prices of all pieces of size smaller than n. Determine the… Read More »

Given a sequence, find the length of the longest palindromic subsequence in it. As another example, if the given sequence is “BBABCBCAB”, then the output… Read More »

scanf family functions support scanset specifiers which are represented by %[]. Inside scanset, we can specify single character or range of characters. While processing scanset,… Read More »

Hamiltonian Path in an undirected graph is a path that visits each vertex exactly once. A Hamiltonian cycle (or Hamiltonian circuit) is a Hamiltonian Path… Read More »

In the previous post, we discussed Finite Automata based pattern searching algorithm. The FA (Finite Automata) construction method discussed in previous post takes O((m^3)*NO_OF_CHARS) time.… Read More »

Given an undirected graph and a number m, determine if the graph can be colored with at most m colors such that no two adjacent… Read More »

The C99 standard allows variable sized arrays (see this). But, unlike the normal arrays, variable sized arrays cannot be initialized. For example, the following program… Read More »

Given a number x and two positions (from right side) in binary representation of x, write a function that swaps n bits at given two… Read More »

Given a text txt[0..n-1] and a pattern pat[0..m-1], write a function search(char pat[], char txt[]) that prints all occurrences of pat[] in txt[]. You may… Read More »

The following is a description of the instance of this famous puzzle involving n=2 eggs and a building with k=36 floors. Suppose that we wish… Read More »

Write a function to check whether two given strings are anagram of each other or not. An anagram of a string is another string that… Read More »

Given a Directed Graph and two vertices in it, check whether there is a path from the first given vertex to second. For example, in… Read More »

Create a data structure twoStacks that represents two stacks. Implementation of twoStacks should use only one array, i.e., both stacks should use the same array… Read More »

Given a Binary Tree, find the maximum sum path from a leaf to root. For example, in the following tree, there are three leaf to… Read More »

Given a directed graph, check whether the graph contains a cycle or not. Your function should return true if the given graph contains at least… Read More »