Facebook Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




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

In a distributed system, generally a global clock is maintained for the purpose of sychronization. In absence of global clock, the distributed systems send a copy of their local clock (refer Chandy-Lamport algorithm or Vector clocks). A similar way of transmitting the count of the user access should be designed.
Note: The above text is not a solution for this question. It is just a thought process that I have shared.

- Learner September 15, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Though why not this be a trick maintain a counter type variable when a particular system gets a visitor he reads the count incr the count and then when the new user enters other system , inc the counter,when he gets new user , i guess before a traffic is split they come to a central point where we can keep this counter variable , when counter reaches 1000,i am done , dont know if its correct

- unknown September 19, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I believe it is the same problem as to get the kth element from multilple array list, except arrays are far from each other. each array list is sorted by time. right?

- yj October 01, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think your answer is partly correct. your solution assumes that the processing of the data will be one offline. say we have server1 with array1, server2 with array2,..., servern with arrayn so we can save in those arrays the user + time of entrence to google.com and then to sort those arrays offline by date and find the 1000th visitor by this order.

the other possibility is to found the 1000th user online. in this case i think each time a user visits google.com from one of the servers a request sould be sent to a "counting server" (server which purpose is to arrange the users by they time of entrence) with the user details + time of entrence to google.com. I suggest to use counter + ordered data structure like balanced binary serach tree that in counting serve enables to insert a new entry user in O(logn) operations. each request processed is of course increamenting the counter by one.
note that we can not assume the order in which the request are processed in the counting server due to communication isues. this means that for instance user1 can access google.com in server1 before user2 access it from server2 but the counting server might get the request to register user2 before user1. the only assumption i must make is that there is maximal time for any request to arrive to the counting server. lets say it is n sec then if the server counter reaches 1000 then we have to process the requests coming in the next n sec one of those requests contains the 1000th user.

- dlev October 08, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think each server can maintain their own record of userid and timestamp (considering their clocks are synchronized) and then send a copy of it to a central server. At the central server, you just need to do an external merge, because all the lists from servers would be sorted. Is it the right approach ?

- Raj March 06, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

O noo i dont know how answered for this question((

i try my answer

Answer

1. module User
2. next, api User
3. next getUser by id method
4. getUser(1000)
5. in model after database find user by id

or just view in database user id

How me correctly answered for this question??


SORRYY IS NOT 1000 USER is just visitor hmmm i think..


IF VISITOR THEN:

1. count visites
2. if COUNT vistes == 1000 then look ip user

Right??

- nosay December 22, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 votes

How is this a distributed system? Please read the question.

- Anonymous September 14, 2012 | Flag
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 votes

Like it's gonna work on an international level website. Idiot.

- Anonymous September 14, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

sam? who dat?

If it name of the fail hackr, at least tell "pwned by Sam". Nd what kind of hacker name is Sam?

- Anonymous September 14, 2012 | Flag


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