# A General Observation

From the result, we could see that:

# Approach

From the last section, we know our propose is to calculate:

At the same time, we have a general thinking which is:

First of all, it gives these definitions:

I will give you an example:

Then, we could know these (Explaining an example):

# Algorithm

This section is for programming.

Let’s look at some difinitions first:

Explaining them by this example:

The pseudo code is like this:

Make a mapping:

The result could be:

# Evaluation

Calculating the matrix S: O(nk)

Calculating combination number: O(1)

Calculating each Nx: O(n)

As for the FOR loop: O(nk)

So:

The time complexity is O(n•k).

The space complexity is O(n•k).

Comparing to the other programs: