link to Code : https://ide.codingblocks.com/s/261072
My approach works in O(m*n), ans it should work as n & m are <= 1000, but it is still giving me TLE in 3 testcases.
Don’t give me the solution, I just want to know what am i doing wrong ?
link to Code : https://ide.codingblocks.com/s/261072
My approach works in O(m*n), ans it should work as n & m are <= 1000, but it is still giving me TLE in 3 testcases.
Don’t give me the solution, I just want to know what am i doing wrong ?
@O17LPOLA020011
Your logic is correct but time complexity of your code is little bit high. I am suggesting two thing, changing them will pass all testcase.
@O17LPOLA020011
I have updated your code as per above changes and it’s working for all cases. Check it here
Thank you abhishek it solved the issue, got AC !
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.