Google Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
0
of 0 vote

how can a better solution be a loop one.. I think Memoization is better ...!! wat say

- scofield January 18, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

there is a O(log n) algorithm using matrix multiplication.

- Anonymous January 25, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Its matrix exponentiation not matrix multiplication. Even using dp and knowing the relation b/w f(n) and f(n/2) we can solve the problem. Check wiki for the relation b/w f(n) and f(n/2)

- Anonymous January 26, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

def fun(n,memoryDict={}):
          if n == 1:
             return 1
          if n == 2:
             return 1
          if n-1 not in memoryDict and n-2 not in memoryDict:
             return fun(n-1,memoryDict) + fun(n-2,memoryDict)
          elif n-1 in memoryDict and n-2 not in memoryDict:
             return memoryDict[n-1] + fun(n-2,memoryDict)
          elif n-1 not in memoryDict and n-2 in memoryDict:
             return fun(n-1,memoryDict) + memoryDict[n-1]
          else:
             return memoryDict[n-1] + memoryDict[n-2]
#done

- weijiang2009 February 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

fib(2n) = fib(n+1)*fib(n) + fib(n)*fib(n-1)
= fib(n)*(fib(n+1)+fib(n-1))
= fib(n)*(fib(n)+2*fib(n-1))

fib(2n-1) = fib(n)^2 + fib(n-1)^2

- yinjike March 20, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

// prints the nth fibonacci number based on the input valuye of n



# include<stdio.h>
# include<conio.h>
void main()
{
int a=0,b=1,c=0,n;
clrscr();
printf("Enter the number of fibonacci series\n");
scanf("%d",&n);
while(1)
{
if(c==n)
{
printf("%d",a);
break;
}
a=a+b;
b=a-b;
c++;
}
getch();
}

- Coder August 09, 2013 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More