febinrasheed
BAN USERTernary search tree will be a good solution. It will not use extra space like trie.
The ternary search tree contains three types of arrows. First, there are arrows that correspond to arrows in the corresponding trie. Traversing a down-arrow corresponds to “matching” the character from which the arrow starts. The left- and right- arrow are traversed when the current character does not match the desired character at the current position. We take the left-arrow if the character we are looking for is alphabetically before the character in the current node, and the right-arrow in the opposite case.
.
A
: \
B B
: :
C C
/ : :
B D D
:
A
The elements are ABCD,ABBA,BCD
- febinrasheed July 03, 2014@rodrigo. Can you please explain how the condition 'a' and 'c' are satisfied in the two for loops?
- febinrasheed June 12, 2014
I have a basic implementation for the requirements mentioned in the question. It should not be compared with the actual deferred and promise implementation.
- febinrasheed August 29, 2014