Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I have an undergrad degree in math, a master's in applied math (focusing on MCMC statistical stuff), and a master's degree in electrical engineering (focusing on computer vision), and I did not know this, and it would have taken me more time than was allotted in the interview to derive it for myself. I feel that when I was asked and I said, "I don't know" it was the unequivocally right thing for me to say to capture the status of my knowledge about it, even if I could have derived it with an extended amount of time.

I think this is still fairly obscure, because my first inclination was to do a simple for-loop over the integers between the two end points along one axis, and then compute the floor of the equation of the line evaluated at that point and just check if it was in fact on the line. The context of the interview did not suggest that non-algorithmic thinking was up for discussion, at least at that moment.

In a short period of time, after doing two other programming questions, the idea that a simple formula existed didn't even cross my mind, and in a regular day-to-day job this is absolutely something I would research rather than just know off the top of my head. I'm not saying that as a system engineer or something, but as someone who has always worked directly in a quantitative modeling, statistics, and math capacity, and is seeking that same kind of work going forward.

I don't really know what this means, other than to say that I did a whole bachelor's degree in math, from real analysis to combinatorial algebra, from boundary value problems to the Sylow theorems, from the formal definition of Turing machines to Jordan Canonical Form, and then did 3 more years of graduate level math, and I feel 100% comfortable with myself when I say I never would have independently thought of this GCD-based solution in a short, timed setting.

The fact that I know how to do it now is also 100% artificial, based only on the happenstance of having been asked it in an interview. If I was asked it again, I feel the right thing to do would be to say: "I know how to solve this because I've seen it before, but my solution is superficial, and if you ask me something else in this area, like say what is the intuition behind Pick's Theorem, I will not have any kind of quick command of that topic and would need to research it." Of course, such honesty just gets you rejected, but still I feel it is the most intellectually honest thing to say.



I really feel for your personal situation, and I appreciate your candor here.

Unfortunately, I come from the school of thought often derided hereabouts that this is an excellent interview question, and your unwillingness to engage with the question would've gotten you a bad score for that interview.

Generally speaking I think it's great to start with:

A) I don't know a great solution to that! Would you like me to brute force it? If I, the interviewer, am looking for brute force I'll say yes, code it up, but if not I'll say no, imagine we've already brute forced it and now we've found we need to optimize

B) I won't care if you actually figure out the precise closed form gotcha answer, but I'll want you to engage seriously. It's a test of whether you can discuss and identify patterns in a coherent way when working with a colleague, which is probably the most important signal for me, second only to "will this person get things done in a normal 40 hour work week"

It's entirely possible the interviewer was just a jerk, and wouldn't engage with you, and I feel bad for people who freeze in high pressure interview situations. But at first blush, your response sounds like you wouldn't engage with the problem at hand, and that just isn't the way to go in an interview, if at all possible.


I did A) and gave the for-loop algorithm that examines each integer in the range on one axis, computes the value of the line at that point, and checks if it's also an integer.

The interviewer said this works, asked me the time complexity (trivially O(N), where N is the number of integers in the range on that axis), and seemed happy.

Then he asked if I knew a way to do it using the GCD. I said I did not know off the top of my head, and then he concluded the interview and left no time for me to ask questions.

I think your characterization that I "didn't engage" is not right. The interviewer was also clearly not looking for someone who needed paper and pencil to work out this property, but instead specifically for someone who "just knew" it as an immediate trivia fact.

FWIW, I don't agree this is a good question. It's so-so, and it's fine if the goal is to work through it, but that was not at all the case.

I should also add that I consider myself reasonably good at dumb-shit tricky interview questions. I've done well in stereotypical finance interviews asking riddles, card shuffling tricks, colored balls in urns, drunk man sitting in the wrong airplane seat, etc., as well as more formal probability questions. This simply just came down to me not making an instantaneous connection between the number of integer lattice steps between the end points and the GCD of the ranges. I don't think it's the same as freezing, it's just that that knowledge would never have been accessed in the particular interview setting. It's just not how I think about that problem, and never would have been.

I'm certain you could devise endless algorithm trivia just the same. Print a binary tree in some weird order, rotate a 3D data array, etc. The one and only way I'd ever solve anything at all like that is slowly and by drawing lots of pictures, making some candidate code, putting it into an interactive programming environment with small toy examples, and iterating.

And in all my professional experiences, including a high-intensity quant finance job, that has been more than good enough for any job-related problem, and has also been what everyone else did. Only in interviews have I ever encountered anything like this.


Thanks for your response.

Given your clarification (alternately, perhaps I misunderstood your original post) I retract my criticism. If you drew a picture and engaged, and he actively wanted a closed form and didn't want to see you work it out slowly, then that's a poor interviewer, not on you at all!

I will note that I do occasionally ask "do you happen to know if there's a closed form" for things, as an extra credit kind of thing, making clear I'm curious and I don't expect a yes. Someone could easily get the impression this is a high stakes question if I wasn't clear it's not; conceivably that was the intent in this situation.

But any which way, sounds frustrating and the interviewer was either a jerk or unclear.


Hmm - so what was the problem statement, exactly? (I may have been thinking of something related, but different).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: