facebook Interview Questions | Glassdoor

Companies matching "facebook"

Facebook Interviews

www.facebook.com /  HQ: Menlo Park, CA

5,340 Interviews

3.1 Average

Workplace from Facebook Interviews

HQ: London

0 Interviews

Not Yet Rated

Social Charlie Interviews

www.socialcharlie.com /  HQ: Brisbane

0 Interviews

Not Yet Rated

facebook Interview Questions

Sort: RelevancePopular Date

Write some pseudo code to raise a number to a power.

11 Answers

pretty trivial...

int raise(num, power){ if(power==0) return 1; if(power==1) return num; return(raise(num, power-1)*num); }

double Power(int x, int y) { double ret = 1; double power = x; while (y > 0) { if (y & 1) { ret *= power; } power *= power; y >>= 1; } return ret; }

Suppose you have a matrix of numbers. How can you easily compute the sum of any rectangle (i.e. a range [row_start, row_end, col_start, col_end]) of those numbers? How would you code this?

8 Answers

If you were handed 50 new target accounts how would you start?

1 Answer

You have two lightbulbs and a 100-storey building. You want to find the floor at which the bulbs will break when dropped. Find the floor using the least number of drops.

38 Answers

You're about to get on a plane to Seattle. You want to know if you should bring an umbrella. You call 3 random friends of yours who live there and ask each independently if it's raining. Each of your friends has a 2/3 chance of telling you the truth and a 1/3 chance of messing with you by lying. All 3 friends tell you that "Yes" it is raining. What is the probability that it's actually raining in Seattle?

38 Answers

Write a SQL query to compute a frequency table of a certain attribute involving two joins. What if you want to GROUP or ORDER BY some attribute? What changes would you need to make? How would you account for NULLs?

26 Answers

Given an input array and another array that describes a new index for each element, mutate the input array so that each element ends up in their new index. Discuss the runtime of the algorithm and how you can be sure there won't be any infinite loops.

26 Answers

Given input: // could be potentially more than 3 keys in the object above items=[ {color: 'red', type: 'tv', age: 18}, {color: 'silver', type: 'phone', age: 20} ... ] excludes=[ {k: 'color', v: 'silver'}, {k: 'type', v: 'tv'}, .... ] function excludeItems(items, excludes) { excludes.forEach(pair => { items=items.filter(item => item[pair.k] === item[pair.v]); }); return items; } 1. Describe what this function is doing... 2. What is wrong with that function ? 3. How would you optimize it ?

23 Answers

Given an list A of objects and another list B which is identical to A except that one element is removed, find that removed element.

20 Answers

Implement a function rotateArray(vector<int> arr, int r) which rotates the array by r places. Eg 1 2 3 4 5 on being rotated by 2 gives 4 5 1 2 3.

18 Answers
110 of 3,585 Interview Questions