Microsoft Interview Question
Software Engineer in TestsCreate 2 suffix tree(1 for inclusion and other for exclusion) with all these inputs in reverse order
eg
Suffix tree input will be
moc. [this is for .com]
moc.tset. [this is for test.com]
ni.oc
Reverse the input and check for its presence in this suffix tree and calculate the length matched as well.
Search for string in suffix tree will be taking O(n) time, n being the length of the input to be searched
when traveling the suffix tree, and we hit a '*", it means it matches in this suffix tree and we do not need to travel much deeper in the suffix tree.
Not really...
Input can be like porn.*.com in which case we should go deeper.
Am I missing something?
The interviewer was expecting some Datastructure implementation,I started saying all the datastructures i know:)..I used N-ary tree for Included and excluded list
- C# September 04, 2010root
.com .net
.test .abc .xyz .*
I would create a tree from input string and would find if the tree is subtree of the Included and Excluded trees and respective heights which determine the best match..I am sure this is the worst way of doing it, any other DS implementations here..