Linkedin Interview Question for Software Engineers

Country: United States
Interview Type: Phone Interview

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

``````double pwr(int n, int k) {
double r = 1;
int i = (k > 0? k: 0 - k);
while(i-- > 0) r *= n;
return (k > 0? r: 1/r);
}``````

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

``````public double myPow(double x, int n) {
if(n == 0)
return 1;

if(n < 0){
if(n == Integer.MIN_VALUE){
n = Integer.MAX_VALUE;
if(x < 0)
x = -x;
}else{
n = -n;
}

x = 1 / x;
}

return (n % 2 == 0) ? myPow(x * x, n / 2) : x * myPow(x * x, n / 2);
}``````

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

``````def power_function(n,k):
sump= 1
if k > 0:
for _ in range(k):
sump = n*sump
return sump
else:
k = k*-1
for _ in range(k):
sump = n*sump
return 1/sump``````

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

``````public static double findPower(int n, int k) {
if (k == 0) {
return 1.0;
}
if (k < 0) {
return 1 / findPower(n, k*-1);
}
return n * findPower(n, k-1);
}``````

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

``````public static double findPower(int n, int k) {
if (k == 0) {
return 1.0;
}
if (k < 0) {
return 1 / findPower(n, k*-1);
}
return n * findPower(n, k-1);
}``````

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.

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.