Facebook Interview Question for Software Developers


Country: United States




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

The output seems to be wrong I guess

After first transformation , we get (3,-1,4,-1,2) , the output is 7
After second transformation , we get (3,4,-1,2,-1) , the output is 8

We can use Kadane's algorithm to find the max sum subarray

- Anonymous October 29, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I thought same at first but I guess they are considering array from position 1 so the case will be L-1 and R-1.
(I guessed that from the test case given)

- Anonymous October 29, 2018 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Using Kadane's for each query, we will end up with time O(q*n). What if q and n are of order 10^5. Can we do better in time?

- Anonymous November 03, 2018 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Output given seems to be wrong 

After first query the array is (3,-1,4,-1,2), output is 7
After second query the array is (3,4,-1,2,-1), output is 8

- Anonymous October 29, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The Li and Ri don't start at 0. They start at 1. So the indices are Li-1 and Ri-1. After that it's a normal 'return the maximum continuous sum of an array'.

- Josh October 29, 2018 | 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