My first thought made it unnecessarily difficult. Well, the correct solution falls into a typical pattern: use DP to calc cumulative results of each cell, and then we use a sliding window to find max rect btw. 2 given rows.
https://www.hackerrank.com/challenges/mr-k-marsh/editorial
时间: 2024-10-01 02:57:31