Given a grid of 2 × 1 tiles. We have to find the maximum sum of the absolute difference of the number in two consecutive tiles , such as that arrangement covers the entire grid.
The problem can be easily be solved using DP.
The tiles are 2X1 rectangular ones. Now let the grid be a[N] , where N is the length of matrix.
let dp[i] denote the maximum sum of the arrangement till length i.
We can either add a single vertical brick to the grid of length i or we can add two horizontal bricks to the grid. We just have to see which one gives the maximum answer