Google Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




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

double Year(double x1,double x2,double R){
// If I need to check data
return log(x2/x1)/log(1+R);
}

- Jeff April 20, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
2
of 2 vote

If we know the formula of compound interest then this Question is Piece of Cake. Isn't?

- Andy2000 September 10, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int noYears(double x1, double x2, double R )
{
    int n=0;
   
   while ( x1 < x2 )
  {
       n++;
       x1 = x1 + x1*R ;
  }
if( x1 == x2)
    return n; 
else
   return -1;
}

- siva.sai.2020 April 21, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

@siva.sai.2020, your solution works only if n is an integer.
It doesn't work if n needs to be 1.5 years e.g.

- mytestaccount2 October 02, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

C++

int years (double &x1, double x2, double coef, int n) {

if ( x1 * coef > x2 ) {
return 0; }

int m = years(x1, x2, coef*coef, 2*n);

if ( x1 * coef < x2 ) {
x1 *= coef;
return m + n;
}
return m;
}

- yongning April 29, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static int getN(double r){
HashMap<Integer, Double> map=new HashMap();
int n=1, pn=0;
double v=(1+r), pv=1;
map.put(0, 1.0);
while(v<2){
map.put(n, v);
pn=n;
n*=2;
pv=v;
v=v*v;
}
if(v==2){
return n;
}
int c=pn;
double cv=pv;
while(n>=1){
n=pn;
pn/=2;
if(cv*map.get(pn)<2){
c+=pn;
cv*=map.get(pn);
}
else if(cv*map.get(pn)==2){
c+=pn;
return c;
}
}
return c+1;
}

- Anonymous May 16, 2012 | 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