4 ms·
Before it was such a cliche, it was actually a great question. Open ended, allowing you to gauge how a candidate deals with unknown problems; answers can focus
by roel_v 9y ago
Before it was such a cliche, it was actually a great question. Open ended, allowing you to gauge how a candidate deals with unknown problems; answers can focus on any part of what happens, giving you an idea of where the candidate has most experience; lots of opportunities to ask questions to go deeper; but also lots op opportunities to say 'yeah let's just skip this part'.
As a candidate, I loved the creativity in it, and the chances it gives you to show off knowing things that you don't necessarily need to know to do a certain job but will still make you better at it than others. Say, when you're an (average) web dev, you don't need to know much about DNS. But pointing out the difference between an A and an MX record shows you have deeper knowledge than many, or at least that you've managed some systems before.
Look, I'll admit that I too have at some point asked people 'what's the difference between an object and a class'. But that's such a shit question, today I'd only do it after having asked some other questions they completely bombed to check if they know anything at all, or after apologizing profusely for the question and blaming it on 'standardized interviewing procedure' or whatever.
I deal a lot with spatial information systems; here's my favorite question I used to ask back when I interviewed people: consider a matrix A of dimensions M x N. Assume that that matrix represents a height map, i.e. each value represents the elevation at that location of a (discrete representation of) a terrain. How would you go about filling this matrix to make it represent a pyramid, i.e. the center cell having the highest value, linearly going down to 0 (or 1) at the border cells? Start by enumerating the assumptions you make, pick the ones that make your solution simplest, then go from there describing how you'd go about relaxing the constraints of your assumptions.
Then I'd draw a sample on a small 5x5 matrix.
I've had people who couldn't understand the problem no matter how hard I tried; and then I had people who would insist on showing 5 different ways of doing it complete with big O notation (in both cycles and memory) to illustrate the trade offs.
Anyone else have any favorite interview questions they came up with themselves that you think are a good representation of your field?
- IIAOPSW 9y agoI assume my code knows (or can readily find) the value of M and N. The max_height of the pyramid is ceil(M/2) + ceil(N/2). The height of every point in the matrix can be readily calculated by taking its Manhattan Metric distance from the center. The equation is max_height - (floor(abs(i-M/2)) + floor(abs(j-N/2))). O(MN) operations are needed. The ceils and floors are there to deal with the case that M or N is even. I did this in my head so there may be off an off by one error which is easily remedied. I forget terminology. Object is an instance of a class right? Did I get the job?
- jwilk 9y ago> Manhattan Metric Nope. All border cells are supposed to be 0, but they have different Manhattan distances from the center. > Object is an instance of a class Correct.
- StevePerkins 9y agoThe question statement above calls for border cells to have a height of "0 or 1". Perhaps to give the candidate some fudge-factor for matrices having an odd number height or width. I realize that this is a contrived testing problem, but to me a pyramid with zeros in the border cells sounds wrong. The area just beyond the border should be zero. Being within bounds of the pyramid intuitively should imply some non-zero height.
- roel_v 9y agoYeah borders being 0 is weird, but it's not material to the question, and for some reason someone once thought this was how it was supposed to work - I never cared about details like that.
- SmallDeadGuy 9y agoActually, if your M/2 isn't integer division (which I assume is the case from your use of ceil around it first), your 5x5 pyramid would look like this: 23443 34554 45665 45665 34554 Using max_height - (abs(i - floor(M/2)) + abs(j - floor(N/2))) would give the properly-centered pyramid: 23432 34543 45654 34543 23432 Your max height should really be just max(ceil(M/2), ceil(N/2)) for a height of 3 going to 1 at the edges or floor(M/2) for 2 to 0. Using both Manhattan distances gives you an octagon-base pyramid (approximated to the square shape) when really you just want the max of both distances: max_height - max(abs(i - floor(M/2)), abs(j - floor(N/2))) gives: 11111 12221 12321 12221 11111 But this only works for square pyramids, using 3x5 you get: 12221 12321 12221 If you want a rectangle pyramid, use min manhattan distance from edge (don't need a max height then): 1 + min(i, N-i-1, j, M-j-1) gives: 11111 12221 11111 or for a 7x10 grid: 1111111111 1222222221 1233333321 1234444321 1233333321 1222222221 1111111111 Python 3 code for those who want to test themselves: N = 7 M = 10 for i in range(N): print("".join(str(1 + min(i,j,N-i-1,M-j-1)) for j in range(M)))
- bicubic 9y ago> I've had people who couldn't understand the problem no matter how hard I tried I understand the problem you're describing very well, but I had to read the entire problem statement to understand what you're talking about. Making someone understand is a two way street, and half of it is about you communicating the problem effectively. That's not to say you did a bad job, but for me the signal to noise ratio of that problem statement was low and made me question whether I understand what you're actually asking. If you said 'draw a height map of a pyramid on a 5x5 grid', that'd be far more clear.
- roel_v 9y agoWell it's not like I would read it out loud like I wrote it down here, plus I did say I also gave them an example. I did start out calling it a 'height map' for example, because well that's what it is, but there are plenty of people who don't know what that is. Damned if you do damned if you don't I guess.
- bogomipz 9y ago>"Before it was such a cliche, it was actually a great question. Open ended, allowing you to gauge how a candidate deals with unknown problems ..." Wait isn't it still an open ended question with answers that can focus on any part of what happens? Why would the fact that it's "cliche" change that? You can go memorize that post but unless you really understand TCP, HTTP, networking, DNS etc. it's still going to be really apparent to an interviewer who does by simply digging further into just one of those aspects.
- roel_v 9y agoWell it loses much of its effectiveness when people can study for it. Plus I didn't say it was no longer open ended, just that it's no longer a great question, because everybody asks it.
- bogomipz 9y agoNo, that's the beauty of of an open ended question it doesn't lose its effectiveness. There is no wrote memorization for an answer. An example of a question that loses its effectiveness because people can study for it is "reverse a linked list"
- roel_v 9y ago*rote memorization Either way, I guess we'll just have to agree to disagree. Even for open ended questions, in my experience it makes a big difference whether someone has prepared for it, and a weak candidate can prepare enough to appear (much) better than he/she actually is.
- bogomipz 9y ago>"*rote memorization" Mea culpa, yes I meant write "rote." Cheers.