4 ms·
I interviewed with Facebook in March for a front-end developer role. It was an insulting experience. The tech screen was with some low-level engineer. The first
by geuis 18y ago
I interviewed with Facebook in March for a front-end developer role. It was an insulting experience. The tech screen was with some low-level engineer. The first(and only question before I hung up on him) was to write a function in javascript to return the square root of a number.
My answer in 15 seconds:
var sqr = function(e){
return Math.sqrt(e);
}
Easy enough. But no, he wanted a function that demonstrated an algorithm to find the square root. Ok... I said. I spent a minute trying to salvage some odd details from high-school algebra and basically came up blank. I was thinking, well this isn't going to look good on me. I readily admit to him that my knowledge of figuring out square roots by hand is a rusty, having been out of high school for 12 years(even though in retrospect, this was something we were never really even taught anyway). But surely this guy, who is screening me for my ability to do front-end coding, will move on and start asking me some hard problems about javascript, css, cross browser problems, etc. No.
We spend the next 6-8 minutes with him circling back on his square root problem. I tried a couple more times to answer this question that is completely unrelated to the job I'm interviewing for. Finally, I get so fed up with this moron that my internal ticker clicks over and I realize, "Even if I get this job, I'm going to be dealing with these kinds of nazel-gazing engineers every single day. Not an environment I want to be in." I thanked him for his time, and he acts surprised and says "Are you sure? After everything it took to get to talk to me?". Yes, I say. I'm quite sure. >Click.<
I realized a long time ago what kind of people these are. When I was growing up, the garbage truck would come by on Tuesdays and Thursdays. When we first moved to the neighborhood, we would put our garbage out by the mailbox and some days it would be picked up and sometimes not. We would complain and nothing would change.
After a few weeks, I was standing out front when they came by. I noticed that everyone had their trash bags on the right side of their mailboxes. That morning, I had done that as well. But some new neighbors down the street had put theirs out on the left side of their mailbox. The truck comes by, grubby guys grabbing/throwing, grabbing throwing. All the garbage gone, except for the neighbors. The next time, I purposely left ours on the left side. Didn't get picked up that day.
So that was the day that I realized these guys had their Line In The Sand. It was Their Way or the Highway. They had a really crappy job. Probably crappy lives at home because they're garbage men. This was Florida, not NYC. There's no glamor or high-pay there. This was the one place where they were the kings, the arbiters of Pickup Or Not. This was the one point of control over their lives they could influence, and they grabbed onto with both hands and some toes.
So this little middling engineer at Facebook had his Line too, in the form of a square root function that Had To Be ANSWERED! "You shall not cross!" He exclaims internally. I'm positive he was quite satisfied with himself after I hung up. Some self congratulation at keeping another peasant out of the castle halls. Kind of like the junk yard dog on a chain behind the fence. Smug in barking and keeping away the kids, but still chained to his dog house.
- furburger 18y agohaha the amusing thing is that he himself likely only looked up the newton-raphson method ten minutes before phoning you. sadly that is the case for many of these mensa-test mental masturbation questions...if you had asked your interviewer the day before, they too would have drawn a blank. you would think it would suffice to just tell him, yeah, i am aware that the newton-raphson method exists, and what it is supposed to do.
- adr 18y agoYou can also use binary search to approximate the square root of a number.
- furburger 18y agowell the point is, and i think this is the original poster's point...questions like this are not relevant to what facebook is doing, and even if it is, its the kind of thing you look up.
- albertni 18y agoIn Facebook's defense (I have no affiliation with FB, and in general am not a big fan of them), they probably weren't looking for somebody to whip out Newton's method, but rather just binary search. Everyone who says "this question is completely irrelevant" isn't completely right. This question would be completely irrelevant if they were exclusively looking for a "fancy" square root finding technique. However, binary search is a pretty basic algorithm - the trick here is to recognize that such a basic algorithm can be applied to a seemingly unrelated problem. If Facebook is testing to see if people can connect different parts of their knowledge (square root function is strictly increasing, something that everyone knows to be true at least intuitively, combined with the fact that binary search can then be used in such a situation), then it's a reasonable question to ask. Maybe not for a front-end developer though.
- patio11 18y agoYou can also use a lookup table, an AJAX call to a square root web service, using the canvas and drawing appropriate geometric shapes then measuring, or, if you have a bit of free time, implementing code which has commercial value, accepting money for it, and then going to Radio Shack and buying yourself a calculator with a square root key. But personally, yeah, I'd use Math.sqrt.