Google Interview Question
1,220 Interview Reviews |
Back to all Google Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Software Engineer at Google:
Helpful Question?
Yes |
No
Inappropriate?
Answers & Comments (3)
1 of 1 people found this helpful
99 = 2 * 7 * 7 + 1 = 2 * 7 ^ 2 + 0 * 7 ^ 1 + 1 * 7 ^ 0 = 201
Here's the code that does this in general:
String convertToBase(int num, int radix)
{
StringBuilder sb = new StringBuilder();
int n = num / radix;
int lsd = num % radix;
do
{
sb.insert(0, lsd);
lsd = n % radix;
n /= radix;
}
while (n > 0);
sb.insert(0, lsd);
return sb.toString();
}
Helpful Answer?
Yes |
No
Inappropriate?
if (n<r)
digit = n
else
digit = n%r
n = (n - digit) / r
convert(n, r)
print digit
convert()
Helpful Answer?
Yes |
No
Inappropriate?
To comment on this
question,
Sign In with Facebook or
Sign Up
0 of 1 people found this helpful
by Interview Candidate: