TikTok interview question

a classic 2d dp problem on a matrix