|
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!
|
# ¿ Jul 24, 2016 16:48 |
|
|
# ¿ May 11, 2024 22:17 |
|
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."
|
# ¿ Jul 24, 2016 17:36 |
|
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.
|
# ¿ Jul 24, 2016 19:57 |
|
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: 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." 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.
|
# ¿ Jul 24, 2016 22:13 |