Code : https://ide.codingblocks.com/s/361362
Approach: For every element in the grid that is black, took min of cost painting square of size 0 to max(i, j)+1 where i, j are its position.
Can someone help me in finding the issue in this code.
Code : https://ide.codingblocks.com/s/361362
Approach: For every element in the grid that is black, took min of cost painting square of size 0 to max(i, j)+1 where i, j are its position.
Can someone help me in finding the issue in this code.
I have modified the above approach to check painting cost for every position even if its already white,
https://ide.codingblocks.com/s/361372.
It has passed all cases. But Iām not sure if this is the correct approach as in other doubt responses O(n^5) approach is given.
When I checked similar doubts of this question, hints were given for a 4D dp solution in O(n^5) TC and since my code uses 2D dp, so I wanted to confirm that its correct and is not just passing the test cases on hackerblocks.