Given a sequence, find the length of the longest palindromic subsequence in it. As another example, if the given sequence is “BBABCBCAB”, then the… 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 the Finite Automata-based pattern searching algorithm. The FA (Finite Automata) construction method discussed in the previous post takes O((m^3)*NO_OF_CHARS)… 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 the right side) in the binary representation of x, write a function that swaps n bits at… 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 to… 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

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

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

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 to… Read More

Given two strings. The task is to check whether given strings are anagrams of each other or not. An anagram of a string is another… Read More