Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
UnfurledSails
Sep 1, 2011

I hate it when interviewers waste my time. I'm given a question, so I briefly talk about the simplest, slowest solution before saying "But I think I can do better than that. Let's see what we can do here..." I've had multiple interviews where I was stopped at this point and forced to code the brute force solution and explain it in painstaking detail. Then we just ran out of time when it came to solving the problem in a nontrivial manner. I could have used those extra 5-10 minutes!

Adbot
ADBOT LOVES YOU

UnfurledSails
Sep 1, 2011

leper khan posted:

Bonus points if you get an RJ for being slow/not finishing.

I actually got rejected from a company because "This is a fast paced startup environment, and we prefer people who answer questions as quickly as possible and move on instead of trying to figure out if there is a better answer."

UnfurledSails
Sep 1, 2011

JawnV6 posted:

Wait, rather than let you handwave for your entire time, you were expected to write code and talk about it? Oh how dreadful.

I don't understand what you are talking about. Let's say the interviewer asks me a basic question like "Given a sorted array and an int k, find two numbers whose sum is equal to k."

This was asked of me in a real interview a few months ago, and I went "Okay, this problem can be solved by choosing every pair of ints checking if it's equal to k. This will solve the problem, but it runs in O(n^2), which is abysmal.

"Another way to solve it is if I use a set of "Numbers that I'm looking for", and iterate over the array. Whenever I see a number i in the array I put k - i in the set, and if I ever iterate over an element that exists in the set I've found my numbers. This is O(n) runtime but I now also have to use O(n) space because of the set.

"Can I use less space? Well I've still not used the sortedness of my array to my advantage. So if I use two "pointers", one at the start of the array, and one at the end, I can create a window that shrinks until it points to the numbers I want, or eventually disappears. If left + right == k, we're done. If left + right > k, then right--; if left + right < k, then left++. If left >= right, then we're done.

"This uses no extra space, and I "look" at every element in the array at most once, so the runtime is O(n). Since I must look at every element at least once in a worst case scenario, I don't think I can do better than that."

This is before I code a single thing on the board. If the interviewer stops me and forces me to write the first two answers before letting me to write the last one, I just think it's a waste of my time. Also if I can finish the problem quickly enough he can maybe ask a different version of the problem, for example a case where I can use a number multiple times and need to find the pair whose sum is closest to k instead of just equal.

UnfurledSails
Sep 1, 2011

JawnV6 posted:

Ok, when giving 2sum as a problem you generally start with the unsorted array being passed in since there's an O(n) solution after sorting, so it's kinda asinine to be given the simpler version to start off. But an interview is very limited time and for a lot of places establishing that someone has actually coded and can do it again is what they need to do. I've interviewed people who could say all the right things and couldn't emit a C function signature. If you've never given one of these interviews, count yourself lucky, but acting like you're above it is precisely what the fakers do. Specifically:

Those are what I would call "indexes," not "pointers," which is really obvious once you write some code but in your handwaving explanation sounds like you'd do this with memory indirection in some overwrought manner. It would actually help my opinion of a candidate to see this written out instead of verbally expressed in this manner. Are you aware of what the word "pointer" generally means? Does overloading it here help you significantly?

And a lot of startups get to funding rounds based racing to market/mvp/$milestone on piles of technical debt. It's fine if you don't want to work for a place like that, but treating it like it's some objectively wrong position?

I can't argue with anything you've said here, although I cannot fathom how the kind of people who can't even code up a C function signature got to the on-site stage to begin with. How do they pass the phone screens?

I also remember getting called on mixing indexes (ahem, "indices") and pointers in that interview, and it led to a discussion about instances where actually having pointers would be justified, which was fun.

I probably shouldn't have gotten the on-site for the startup in the first place; they were clearly not looking for someone who had so little work experience.


sarehu posted:

"Indices." :colbert:

And the right answer to the question is to say that you've heard it before, if you have. And then if they want you to solve it anyway, just give them the best answer. Get it over with so you have more time with the next question.

And if you fake reasoning through it I'll think you're a phony.

I had two interviews where I was asked 2sum. First time I saw it, I told him I remember doing it before, but the interviewer wanted me to prove it and give him specifically 3 different ways to do it, so I went through what I said above. I guess he didn't have any other questions prepared?

The second time was much more interesting and fun because the interviewer made some interesting alterations to the question and then kept altering and making it harder every time I told him how I would solve it, eventually telling me to code up the last one in the last 15 minutes.

  • Locked thread