Earlier quoted context omitted.
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…
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 bru…
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.