I tried solving this problem in 2 ways, which are naive checking and dp, using Python. But I can not make it within the time limit. Anybody managed to solve it?
I agree, I tried optimizing the code time and time again, but still failed. Both Java and CPP are fine.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.