1. Write an efficient algo to find longest recurring substring in a string e.g. in banana, it would be 'ana'
Ans : We can use suffix trees to implement this. I will post the exact solution soon
2. Write a function to find intersection of two strings. i.e. characters common to the strings.
For this, the most efficient solution would be to use 26 bits .. one for each character and put zero in all and then wen u encounter a character, just make the corresponding bit 1. For this, we ll need to traverse both the strings only once ands the extra memory that would be required would only be 26 bits :) O(n) solution
1 comment:
Hi Pragya,could you please post the solutions to Amazon interview questions
Post a Comment