Facebook Interview Question
Software EngineersCountry: United States
Interview Type: In-Person
As the function returns an int we suppose we are trimming the decimals and we just only return the int part, e.g. 3/2 = 1.5, result = 1
now we have that a/b = c thus giving us a=c*b, then we need to find a value where c times b is equal to a, so we iterate over the possibles values of c
function divide(a,b) {
i=0;
while(b*i<=a){
i++;
}
console.log(i-1);
}
Looking for interview experience sharing and coaching?
Visit A++ Coding Bootcamp at aonecode.com.
Given by experienced engineers/interviewers from FB, Google and Uber,
our ONE TO ONE courses cover everything in an interview including
latest interview questions sorted by companies,
SYSTEM DESIGN Courses (highly recommended for people interviewing with FLAG)
ALGORITHMS (conquer DP, Graph, Greedy and other advanced algo problems),
and mock interviews.
Our students got offers from G, U, FB, Amz, Yahoo and other top companies after a few weeks of training.
Feel free to email us aonecoding@gmail.com with any questions. Thanks!
- aonecoding June 06, 2017