Given an array of integers, find out number of ways in which you can select increasing subsequences of length k(k<=n).
for eg array is 1 4 6 2 5 & k=3
then the answer is :1 4 5, 1 2 5,1 4 6,
so ways are 3
int solve(int a[], int size, int K)
{
int buf[size][K];
memset(buf, 0, sizeof(buf));
for (int i = 0; i < size; i++)
{
buf[i][1] = 1;
}
for (int i = 1; i < size; i++)
{
for (int j = 0; j < i; j++)
{
if (a[i] > a[j])
{
for (int m = 1; m < K; m++)
{
buf[i][m+1] += buf[j][m];
}
}
}
}
int result = 0;
for (int i = 0; i < size; i++)
{
result += buf[i][K];
}
return result;
}