Discuss: Any better solutions when the size of this problem goes bigger?


  • 0

    I have looked around my fellow's posts. There are mainly 3 solutions.

    1. Just use DFS, recursive call the function.
    2. Try to use some memorization like map.
    3. DP. I just see one solution using a 6D matrix to implement DP. Well, brilliant!.

    All of them works for this small scenario, what if the problem is bigger? Which one do you think is the best? Or some other methods? Why?


  • 0

    Just for those 3, I believe the second one to encode the list into something like a string may work when the problem goes bigger. DFS has the worst time complexity over the 3. And it is sort of bad idea to me to implement a super high dimension matrix for dp.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.