InterviewSkills
BAN USER- 0of 0 votes
AnswersThey gave me some more code. It was building suffix trees. There was a print function there. He asked me the output of the function which was traversing the suffix tree with given inputs and concatenating the output.
- InterviewSkills in United States| Report Duplicate | Flag | PURGE
Software Engineer / Developer - 0of 0 votes
AnswerThey gave me some code. Asked to find out what it was doing. It was a IsPalindrome function. He asked me how would I improve the code. Given function was recursive. I suggested iterative approach. Also pointed out couple of null checks missing. He seemed to be happy with it.
- InterviewSkills in United States| Report Duplicate | Flag | PURGE
Software Engineer / Developer
class Fibonacci
{
static Dictionary<int, int> fibMap = new Dictionary<int, int>();
public static int RunFibonacci(int startIndex, int len)
{
int fib = 0;
if (fibMap.ContainsKey(len))
{
return fibMap[len];
}
if (len == 1 || len == 2)
{
fib = 1;
}
else
{
fib = RunFibonacci(startIndex, len - 2) + RunFibonacci(startIndex, len - 1);
}
fibMap.Add(len, fib);
if (len >= startIndex)
{
Console.WriteLine(fib);
}
return fib;
}
public static void FibonacciTest()
{
RunFibonacci(1, 10);
Console.WriteLine("===");
fibMap.Clear();
RunFibonacci(2, 6);
Console.WriteLine("===");
fibMap.Clear();
RunFibonacci(3, 5);
Console.WriteLine("===");
}
}
@Jay has got the right answer
- InterviewSkills January 26, 2012