Here is the problem.

I have checked the the coefficient of x^n in the polynomial multiplication of the series of power of x…where the start and the end term of the series are determined by the ATLEAST and the ATMOST number of dishes a chef can prepare.

For example in the sample test case I am doing

(1+x+x^2+x^3)*(x+x^2+x^3)…and check the coefficient of x^3

My implementation takes O(T*m*n*n) complexity.

Also the editorial of the problem states that the O(n^3) will pass. So can anyone one suggest me where I am going.

My code is here.