How to solve Coloring Grid CodeSprint 5

The problem statement says:-

Calculate the number of ways to color an N * M grid using K colors. Adjacent squares in the grid should have different colors. Squares are considered adjacent if they share an edge.

1 <= N,M <= 8

1 <= K <= 10^9

link

2 Likes
//