How to solve Under the tunnels and Construct Array?

I couldn’t solve any of them fully ;_;
I solved Construct Array partially with DP.
Ask me doubts for first two if you have :slight_smile:

since you have solved using dp, form a recurisive function and solve it using matrix exponentiation

1 Like

Yeah i need more practise in implementing that.
I was trying to form a mathematical formula there. :confused:

The matrix is
[M^2 - m m] * [m-1 1]^n-2
[ m 0] * [m-1 0]
Then add the top elements for the answer i think


Check this post