Expedia Interview Question for Software Engineer / Developers






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

This is interesting problem we used to solve in college time, Iterative approach is more efficient and faster than recursive approach which consumes a lot of memory and method calls.

- Dilip June 23, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

tradeoff:
recursive functions have a large overhead for function calls. This could lead to slower performance in some cases (eg. factorial). In such a case you'd be spending more time with function call overhead than actually doing the calculations. Iterative is normally faster and efficient, but could be complex to implement as you'd need to implement your own stack & store stuff on it etc.
Recursive is also tricky because it could lead to infinite recursion if you're not careful in making sure there's a base case that gets executed eventually.

- st May 09, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

// n should be positive
int fibonacci(int n) {

                int[] fibonacciArray = new int[n + 1];

                fibonacciArray[0] = 0;
                fibonacciArray[1] = 1;

                for (int index = 2; index <= n; index++) {
                        fibonacciArray[index] = fibonacciArray[index - 1] + fibonacciArray[index - 2];
                }

                return fibonacciArray[n];

        }

- Kapil July 14, 2017 | 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