distinct subsequences


distinct subsequences

A subsequence of a given sequence S consists of S with zero or more elements deleted. Formally, a sequence Z = z1 z2 … zk is a subsequence of X = x1 x2 … xm if there exists a strictly increasing sequence < i1 i2 … ik > of indices of X such that for all j = 1, 2, …, k, we have xij = zj. §For example, Z = bcdb is a subsequence of X = abcbdab with corresponding index sequence < 2, 3, 5, 7 >.§Your job is to write a program that counts the number of occurrences of Z in X as a subsequence such that each has a distinct index sequence. Input§The first li..........



원문링크 : distinct subsequences