## The Longest Common Subsequence

A subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. Longest common subsequence (LCS) of 2 sequences is a subsequence, with maximal length, which is common to both the sequences. Given two sequences of integers, A = [a[1],a[2],..,a[n]] and B = [b[1],b[2],...,b[m]], find the longest common subsequence and print it as a line of space-separated integers. If there are multiple common subsequences with

## Play with words

Shaka and his brother have created a boring game which is played like this: They take a word composed of lowercase English letters and try to get the maximum possible score by building exactly 2 palindromic subsequences. The score obtained is the product of the length of these 2 subsequences. Let's say A and B are two subsequences from the initial string. If Ai & Aj are the smallest and the largest positions (from the initial word) respectively in A; and Bi & Bj are the smallest and the la

## Black and White Tree

Nikita is making a graph as a birthday gift for her boyfriend, a fellow programmer! She drew an undirected connected graph with N nodes numbered from 1 to N in her notebook. Each node is shaded in either white or black. We define nW to be the number of white nodes, and nB to be the number of black nodes. The graph is drawn in such a way that: No 2 adjacent nodes have same coloring. The value of |nW - nB|, which we'll call D, is minimal. Nikita's mischievous little brother erased some of

## Counting Special Sub-Cubes

Given an n*n*n cube, let f(x,y,z) (where 1 <= x,y,z <= n) denote the value stored in cell (x,y,z). A k*k*k sub-cube (where 1 <= k <= n) of an n*n*n cube is considered to be special if the maximum value stored in any cell in the sub-cube is equal to k. For each k in the inclusive range [1,n], calculate the number of special sub-cubes. Then print each (count)k as a single line of space-separated integers (i.e., count1,count2,...,countn). Input Format The first line contains an integer,

## Interval Selection

Given a set of n intervals, find the size of its largest possible subset of intervals such that no three intervals in the subset share a common point. Input Format The first line contains an integer, s, denoting the number of interval sets you must find answers for. The s.(n+1) subsequent lines describe each of the s interval sets as follows: 1.The first line contains an integer, n, denoting the number of intervals in the list. Each line i of the n subsequent lines contains two space-s