|
|
back to boardGreedy algorithm doesn't pass Test 3. Which algorithm to use ? Please don't say just DP+tree. How do you buld a tree ? Building a tree is not problem, we can build the tree using STACK but it gives TLE on test 5. It takes too much time to build the whole tree. In this promlem, order of the words is important, so I have no idea how to use DP. Please, give some hints. Thanks, just DP Similar to Knapsack(I think) and need to store the previous element to recover the path in the end :) In Knapsack order is not important, but in this problem order is important. How do you deal with order ? KNIGHT0X300 is right. It is an example of DP problem. I got AC using Trie Tree and Knapsack DP. |
|
|