Problem in Grand Temple

Testcases correct but TLE for 1 out of 3 test cases.


Please check the code.

Hi Vivek,
First of all use merge sort (or collections sort, Arrays.sort(Array_name) ) to sort row and col arrays. Then just find the maximum difference among adjacent elements of row and col array. The answer will be multiplication of the max row diff and max col diff. Also, you need to subtract 1 from max diff before multiplication.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.