I was reading "Using Tries" on topcoder and so tried to solve MORSE I think it requires Trie and DP. I have implemented a trie but I have not figured out the DP for this case. Can someone please explain me the DP approach ? Thanks.
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3845 |
2 | jiangly | 3707 |
3 | Benq | 3630 |
4 | orzdevinwang | 3573 |
5 | Geothermal | 3569 |
5 | cnnfls_csy | 3569 |
7 | jqdai0815 | 3532 |
8 | ecnerwala | 3501 |
9 | gyh20 | 3447 |
10 | Rebelz | 3409 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | maomao90 | 171 |
2 | awoo | 163 |
3 | adamant | 162 |
4 | maroonrk | 152 |
5 | nor | 151 |
5 | -is-this-fft- | 151 |
7 | atcoder_official | 147 |
7 | TheScrasse | 147 |
9 | Petr | 145 |
10 | pajenegod | 144 |
I was reading "Using Tries" on topcoder and so tried to solve MORSE I think it requires Trie and DP. I have implemented a trie but I have not figured out the DP for this case. Can someone please explain me the DP approach ? Thanks.
Название |
---|
also, before
return res;
there should beif (isValidWord(trieNode) res += D(pos, rootNode);
@Alias: could you please tell me what does NextTrieNodeByLetter() return? if you could explain the approach it would be very helpful
NextTrieNodeByLetter() returns -1 if node trieNode has no edge marked with letter i or corresponding next node. It makes a try to go from node trieNode using letter i. I do not know what else I can say.
morse[] — array of morse strings. A trie is builded from dictionary words.
In my solution dp[i] was number of ways that we can translate an string starting from i-th place of morse string to end of it.