## MobiCastle Interview Question for Software Engineers

• 2

Country: Switzerland
Interview Type: Phone Interview

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

Looking for coaching on interview preparation?
Visit AONECODE.COM for ONE-TO-ONE private lessons by FB, Google and Uber engineers!

System Design (for candidates of FB, LinkedIn, AMZ, Google and Uber etc)
Algorithms (DP, Greedy, Graph etc. advanced algorithms and clean coding)
Interview questions sorted by companies
Mock Interviews

Ace G, U, FB, Amazon, LinkedIn, MS and other top-tier interviews in weeks of training.

Feel free to email us aonecoding@gmail.com with any questions. Thanks!

``````//Extra space O(1) Runtime O(nlogn)
List<Integer> getFibonacciNumber(int[] nums) {
List<Integer> fibonacciNumbers = new ArrayList<>();
Arrays.sort(nums);
int fib1 = 1, fib2 = 1;
for(int i = 0; i < nums.length;) {
if(nums[i] < fib2) {
i++;
} else if(nums[i] == fib2) {
i++;
} else {
int fib3 = fib1 + fib2;
fib1 = fib2;
fib2 = fib3;
}
}
return fibonacciNumbers;
}

//Math Solution: Extra space O(1) Runtime O(n)
List<Integer> getFibonacciNumbers(int[] nums) {
List<Integer> fibonacciNumbers = new ArrayList<>();
for(int n: nums) {
}
return fibonacciNumbers;
}
boolean isFibonacci(int n)
{
// n is Fibonacci if one of 5*n*n + 4 or 5*n*n - 4 or both
// is a perfect square
return isPerfectSquare(5*n*n + 4) ||
isPerfectSquare(5*n*n - 4);
}

boolean isPerfectSquare(int x)
{
int s = (int) Math.sqrt(x);
return (s*s == x);
}``````

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

Iterate through the list and check if 5(Num)2 +4 OR 5(Num)2 - 4 is a prefect square .
5*n*n + 4 or 5*n*n - 4
add to list if true .

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.