anyone who can provide a dynamic programming approach for the question:
I tried, but couldn’t get AC.
If you could share the approach or the code, I would be grateful
anyone who can provide a dynamic programming approach for the question:
I tried, but couldn’t get AC.
If you could share the approach or the code, I would be grateful
Why would you use DP for this problem?
exactly, it can be solved in O(|S|), dp will take at least O(|S|^2).
This is not a DP Problem. It can be easily solved by finding the extreme x and extreme y values that can be reached.