div
BAN USER
Comments (4)
Followers (1)
Reputation 10
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
I dont think building a suffix tree is a good solution as you need to identify all the characters in str2 that occur in str1. the characters of str2 can be spread out in str1
eg:
str1= "monkeydonkey" str2="okden"
Suffix tree can be used to find out the occurance of sub string str2 within str1
I am thinking more like finding the longest common subsequence.
Its a dynamic programming problem
Comment hidden because of low score. Click to expand.
Page:
1
Repjanistbennett, Blockchain Developer at AMD
I am JanisBennett working as a journalist, having years of experience in my career. I have covered various stories.Great ...
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Not sure if somebody has already suggested this approach, we can easily solve this by recursion.
We also need to maintain a hash table to eliminate duplicates
The pseudo code would be as follows
The time complexity would be !n.
- div May 22, 2015