Readit News logoReadit News
kylnew · 7 years ago
I recently got double slammed with 2 graph questions during an interview after having navigated for years without getting a graph question. It's wholly irrelevant to my day-to-day work but I do hobby game development sometimes which involves more needs for graphing. Still, I can't do much of anything with a graph on a whiteboard. Puzzled as to why it's so important to some companies to grill on this stuff, expecting it to be top-of-mind, even for front end roles.
maxcut · 7 years ago
I have given a lot of thought to the interview process over the years. As a candidate I really disliked whiteboard questions and trying to come up with clever solutions on the spot with hard time and resource constraints. I was always frustrated with how different the interview experience was from actual day to day work. As an interviewer I much prefer a hands on experience with internet access. For that I have prepared a short app riddled with some bugs and half baked features to be completed. For me it is really important to see how a candidate copes with an existing codebase as most people work in environments with large and mature ones. It is also important as the interview progresses to see when and how the candidate resorts to online resources and how they conduct their search. Some just continue to bang their head when they encounter a problem or DFS into the first search result they encounter while others cleverly start opening a few tabs and evaluate proposed solutions before selecting the one that is most suitable for the current problem they are trying to solve. Most candidates after completing the interview stated that they preferred this method to 'traditional' ones and some even said that they enjoyed it.
gaius · 7 years ago
Puzzled as to why it's so important to some companies to grill on this stuff

Because contrary to the narrative, there is no shortage of developers, there is in fact a glut so companies can not only afford to be choosy, they actually need to filter early to keep volume of applicants manageable. At least that is my interpretation of the evidence, I am curious if there is another explanation.

I can remember when there really was a shortage of developers, the dotcom boom. Companies couldn’t shove people in the door fast enough, an interview was a quick chat followed by “when can you start?”. Today it’s nothing like that. In a genuine shortage there is no ageism etc either, noone can afford it.

throwawaymath · 7 years ago
"Shortage" is always a funny term in these discussions, and it always starts a debate. It's too simplistic and disagreeable a term.

I agree with your point but I think it should be clarified. There is probably not a theoretical shortage of people who can be called "software developers" compared to the number of jobs available. But I find that shortages are relative. Companies make their own bars for who they're willing to hire, and how far above or below a given baseline level of competency they'd like to target.

Not all software developers with that title can be software developers at any given company. This is not just because they don't know the underlying theory or because they don't know "real" engineering. So it's much harder to discern if there's actually a shortage, because obviously not all jobs with the same title involve the same specialization or skill requirements.

I think that a more charitable interpretation is Google and other such companies use these interviewing practices because their ideation of a "software developer" is substantially different from the all-inclusive title. It's not just an arbitrary way to reduce the stack of resumes, it's an imperfect proxy for their actual criteria.

godelmachine · 7 years ago
If you have read Cracking the Coding Interview, the author describes a guy who was hired in her company because there was super shortage of developers. The guy barely knew HTML. He used to come late to office, play ping pong and take off before sundown.

I believe things were quite similar in India during the dotcom bubble. Candidates were asked to do some addition programs, hir d immidietely, and within weeks their H1B was sponsored.

jopsen · 7 years ago
It's no secret that interviews at crazy, it's like an exam, and you should prepare accordingly. Yes, it's largely irrelevant.

But an engineer who can't reason about DAG, topological sorting, etc, could easily ruin an otherwise elegant architecture :)

WalterBright · 7 years ago
> it's largely irrelevant

Maybe not. Wouldn't you prefer a candidate who did prep work before an interview rather that one who chose to wing it?

platform · 7 years ago
Perhaps I do not quite understand what you meant by 'engineer that cannot reason'.

Somebody might not be able to write on a white board, during an interview a topological sort or find-a-union (https://www.hackerearth.com/practice/notes/disjoint-set-unio... ).

But does it mean that they will ruin 'elegant architecture'? (compared to somebody who passed the topologica sort exam)?

Also, wouldn't an architecture that imposes compile time constraints, good documentation and test cases -- on the usage of its most elegant pieces, be more 'elegant' than the one, that could be easily 'ruined' but somebody who does cannot write out a 'topological sort' during an interview?

nlawalker · 7 years ago
>> Puzzled as to why it's so important to some companies to grill on this stuff, expecting it to be top-of-mind, even for front end roles.

Either they do consider it important to the role, or they are trying to select for young CS grads, or they just haven't tried to do any better in their hiring process, or they don't know how.

cipherzero · 7 years ago
Maybe I’m not like the interviewers/companies to which you’re referring, but I ask a DAG topo sort question (dependency resolution/task ordering) not because I expect the candidate to regurgitate the algorithm but because I legitimately want to see how they work through a problem - especially one they may(hopefully) not be familiar with.

Most of the time I don’t care if they get the optimal algorithm, rather the can think through something and know where problems might be.

Might not be how/why the “others” use that question, but its worked well for me.

meritt · 7 years ago
Because a large proportion of "software engineers" are simply people who know how to use popular libraries/frameworks to crank out a simple website or app (which often satisfies the needs of most companies anyway).

Some companies prefer to hire people who can write software.

timClicks · 7 years ago
Surely most interviewers are interested in things that are slightly more abstract than answers to specific data structure question.

1) has requisite base level of knowledge, 2) shows humility/knows own limits, 3) has an ability to explain complex ideas simply, 4) demonstrates an innate curiosity and 5) can work through problems methodically

xtiansimon · 7 years ago
Once in an interview a senior designer walked in on my interview. They were introduced. Hung out for a minute. Wrote something on the whiteboard, then left. My interview ended, I was left in the room for a minute and I stared at that frackn whiteboard wondering what that was about.

I didn't get the job, but I had to assume this was something that senior designer was into--something they cared about, something they used, a skill they wanted to manage, a subject they wanted to discuss.

User ItsMe000001 says he was asked about a 'right join', choked during the interview, was still hired, and later became the go to guy for writing queries.

If a question is in the interview, it's relevant to someone in some way unless it's a psychological mind-frack test.

So the question would be, Who was also hired, and later had their head flipped?

mianos · 7 years ago
Same, in an interview a few months I got a graph one which I did OK in. Then I got asked to write an algorithm to determine if it is acyclic on not. I could remember the visitation flag but I could not remember, of the top of my head, which side of the recursive call it was on. I picked the later side and obviously failed as I didn't get any offer, although that was more likely due to my age. I dodged a bullet in the end.
ummonk · 7 years ago
Why would you have to remember that to solve it? This is the kind of thing I definitely wouldn't already know, but should be able to reason through.
User23 · 7 years ago
Graphs are arguably the fundamental data structure. If you can’t think about objects and references between them then how do you write nontrivial software?
umanwizard · 7 years ago
Yes but in normal programming it is uncommon to need to write algorithms that traverse the global object graph. You normally care about some local view of it.
jumper_F00BA2 · 7 years ago
When faced with questions that have answers I could obviously discern by writing and running two lines of code, I willfully shrug, answer by intuition, hoping that's the trap for the wrong answer, and wait for a facial expression.

Today I was asked a question about inheritance and references within a constructor, in which the answer was an either/or for the parent or child class.

I threw up my hands and deliberately said "I dunno parent, no wait! Child!" because honestly who cares, when you can figure something like that out without even googling for it.

A question like that is like asking someone what might they expect a Hello World! program to print.

Waste my time, and I waste yours right back. I could care less what you think about me.

throwawaymath · 7 years ago
I don't really agree with these kinds of questions, but to be honest I find your response to be pretty childish. In my opinion it would be better to be honest and say you don't really know, but that you believe you could quickly find out. But your response indicates that you have the potential to be passive aggressive and uncooperative when presented with a question you disagree with.

Now from the interviewer's perspective, they don't know you're absolutely fed up with the culture of tech interviews. They can't see the full interiority of your thoughts. So they can't know why you're reacting like this, all they can see is your behavior. Keep in mind that you're most likely punishing an interviewer who has either been given a mandate for these questions or who doesn't know any better. From your perspective this could be a teachable moment or a way to showcase your thinking.

Even though that might have been a poor question to ask, doing what you did doesn't demonstrate that your time is important. It demonstrates you might have problems being professional and communicating effectively. It signals that you think your time is so important that you're willing to potentially burn an interview to spite someone asking you a question you feel is beneath you.

It's not a good look. Don't give people reasons to write you off.

mosselman · 7 years ago
When do you ever have to rely on 100% top of mind knowledge like that when programming anyway? I usually have a console open and google even fairly trivial things because of how much quicker (second or ~10) it is to look at the API than it is to get it wrong when reloading my code and having to try again.

Usually I challenge getting silly 'traverse this data structure' questions and want to hear what they expect to get out of it.

Side note: The correct expression is "I _couldn't_ care less"

throwaway0255 · 7 years ago
If all the questions were relevant and had objective solutions, they would be put into a lot of situations where they have no justifiable reason to reject somebody that they would prefer to discriminate against.
gameguy43 · 7 years ago
Founder of Interview Cake here. Thanks for the post!

Down to chat about coding interviews and answer questions here!

derpistan · 7 years ago
Hey, I just wanted to say thank you for Interview Cake in general. Your approach of unravelling the solution gradually really helped me think about these problems.

While it wasn't my only resource, it helped me a lot interviewing for Facebook and Google recently, and I got offers from both.

(throwaway account for obvious reasons)

ultrasounder · 7 years ago
Like your throwaway account handle.
gameguy43 · 7 years ago
:)
bogomipz · 7 years ago
Your site looks interesting.

I couldn't help but notice that Golang was conspicuously absent from the list of languages. Might you be adding that in the future?

gameguy43 · 7 years ago
No /specific/ plan to add it yet, but it’s on our radar. Definitely the most requested language.
hmottestad · 7 years ago
Hi. I got an interview question a little while ago that the interviewer said “was not a datasteuctures/algorithm question” because it was too specific. I call bullshit, but I don’t actually know what the algorithm would be called.

Problem:

A tree of resources that you can get granted access rights to. When you get access to a node in the tree, you inherit rights to children transitivley. You can also have rights explicitly blocked. The ordering is important. An example, you start of as head of IT and have all the IT stuff granted, but explicitly no access to the IT security department. Then you make CEO and are granted right to everything, so that should overrule your previous restriction for the IT security department.

philipov · 7 years ago
The problem you described doesn't ask a question. What are they asking you to do: implement the described data structure (not enough information), or untangle their department hierarchy?

I think the correct answer is "IT Security should be a peer of IT, not a subdepartment."

gameguy43 · 7 years ago
Hmmm. Can't get in your interviewer's head, but here's my guess: this might be one of those questions where the bulk of the discussion is supposed to be about weighing tradeoffs of different choices for the data model.

For example: how do you store the explicit blocks? More specifically, how do you articulate that head of IT is blocked from this subtree, but the CEO isn't? Some options:

- store the block as pairwise (individual, subtree)

- same idea, but instead of blocks you store explicit /allowances/ (and allow a tree node to have a flag set of "ignore the tree-based permission system here, and just lock everyone out who doesn't have an explicit permission")

- instead of blocking individuals, you could add an abstraction layer, e.g. user_groups, and assign permissions to /groups/.. You could also add an abstraction layer on top of the treenodes themselves (object_permission_groups?). Different tradeoffs with these options.

Again, hard to know exactly where your interviewer was trying to steer the conversation. But that'd be my guess!

justinclift · 7 years ago
Hmmm, since they specifically said it's not a data structures/algorithm thing, maybe they're looking for other aspects?

One potential that springs to mind is (say) governance or oversight considerations of the given situation?

Not sure how that'd apply directly either though. Feels like there's more info needed from the interviewer first, to give a hint as to the direction. :)

karmakaze · 7 years ago
That would be an access control list (ACL). Find all the matching rules then process them top to bottom keeping track of whether access to the specific resource is allowed or not. Runtime is O(n) where n is the number of rules. There could be improvements but this is pretty straight-forward.
stochastic_monk · 7 years ago
It’s pretty much your meat and potatoes data structures, excepting hash maps. I think a basic understanding of them and collision resolution strategies would benefit a learning developer. (And I'd suggest considering adding them.)

And, as an aside, I’ve found in practice that combining these lego blocks, allows you to build the sorts of specialized, efficient solutions you need.

Perhaps you could add an example of doing that, such as combining a queue with a binary search tree map to emit minimal values over a window. This would be a case where the sorted property of the tree is actually useful, as well.

deckarep · 7 years ago
“Hashtable: like an array but instead of an index you can set arbitrary keys for each value.”

This sounds like a gross over simplification of what a Hashtable really is underneath the covers.

Any candidate that shows up with that definition better be ready to dive in on what it really is and when you’d want to use it.

cup-of-tea · 7 years ago
That doesn't even describe a hash table, it describes an associative array, or map. A hash table as one way to implement that, the other main one being self-balancing binary trees.
ummonk · 7 years ago
Or more broadly, self-balancing trees (the best performing balanced tree, the B-tree, is not generally a binary tree). And then there is the skip list.

Deleted Comment

A_Person · 7 years ago
It just amazes me that employers ask complicated CS-type questions for ordinary programming jobs. I've been out of the game for 20 years, and only did a few interviews anyway (as the interviewer), so what would I know! But FWIW, here's the kind of question I'd ask.

"I'm going to write a few lines of code on the whiteboard, tell me what you think of them." The code would be something like this:

  If f(a,b) then
    X=6
  Elseif flag1 then
    X=8
  Endif
My bet is, people would fall into one of three camps.

(1) The Bemused :-)

These people would have no idea what to say. That would be fine for a new developer, I'd just prod them in the right direction. For example, "what do you think about inline constants?" But if an experienced developer had nothing to say about that code, that would be a big red flag for me.

(2) The Defiant!

These folk would say, "Gee that looks like very old code, I'm really more interested in functional languages, do you guys do any Haskell?" This would also be a big red flag. First, he's saying that he has no interest in my priorities as the interviewer, he'll just ignore my questions and substitute his own. Second, he shows that he's not really interested in code as such. It's like a guy who says he likes cars, you take him around the corner and show him your one-off Porsche EVO hybrid, and he says "Wow, an infinity pool! What did that cost?" Fail.

(3) What I'd Expect

Here's what I'd expect from an experienced developer, off the top of his/her head:

"Ok, I see in-line constants, and short variable and function names. Those are often undesirable, I can talk about that more if you like.

But the more interesting thing, is that X is only set if one of the two conditions is true. If neither condition is true, X does not get set to anything.

That might be a bug: the programmer meant to initialise X before the first test, but forgot. Or perhaps X is initialised much higher up. But if that was the case, I'd like to refactor the code to bring that initialisation closer to the code on the whiteboard; and/or rename X to something less likely to be used by mistake in the middle; or at least, add a comment saying "X initialised above". Or you could just add an else branch to the code on the whiteboard, to ensure that X gets set even when both conditions are false.

Another slight possibility is that when the first condition is false, the second condition is necessarily true, and the developer has written in the second condition as a form of comment. But in that case, I'd rather make it more explicit, by changing "Elseif flag1 then", to "Else /* flag1 must be true */"; or even asserting that, just to be sure.

Also, if the code in question is really complex, or just messy from years of maintenance, there might still be cases where X does not get set at all. In that case you could initialise it to an impossible value, say NULL, right at the start, then assert not null at the end. Or you could even re-write the code in truth table style, which I can talk about more if you'd like."

Me: "The truth table approach sounds good. How would you do that? What kind of data structures would you use?"

And so on.

Does everyone really use CS-type questions these days? Does anyone take the different approach displayed above?

clarry · 7 years ago
I have to agree with Veedrac and idontpost.

My first thought is, "This looks like a snippet of code completely made up or taken out of context and then anonymized by renaming variables. I have no idea what it's supposed to do, I have no idea why I'm looking at it, and I have no fucking idea what the interviewer wants form me, and I don't play guess-the-rules type of games." If this were real code, I'd have context. Not just a snippet. I'd see the things I don't see in the snippet, and I'd know why I'm looking at it and what I'm looking for. In real work, there is always a motivation for everything you do. In this case, there is none. You might as well show a sequence of bits. "What do you think of these bits?"

So by your prejudice, you'd probably categorize me in the first camp. Congrats, you probably turned down someone who's been coding for 20 years. Then again, if this really is the kind of line of business code you regularly deal with, maybe it's for the (my) best.

This is a pattern I see all the time. Interviewers come up with their games with their arbitrary rules and a bunch of prejudice about how a good or bad candidate should react. They think they came up with something clever, they always do. They have no idea.

I get the impression that good people get regularly turned down because they didn't guess the rules of the game right, or they don't even play because they got an offer at some place that doesn't play these silly games. Then there is so much complaining about talent shortage, and complaining about terrible interview practices, and complaining about having to deal with a stack of 1000 job applications.

alangpierce · 7 years ago
> Interviewers come up with their games with their arbitrary rules and a bunch of prejudice about how a good or bad candidate should react.

Agreed that a lot of interviewing issues that I've seen boil down to a misunderstanding of the rules/expectations of an interview, which can be problematic on both sides. Some examples:

* I've had candidates do poorly on a warm-up question because they expect it will be difficult. Ideally, they would say the easy answer they know, but I've had candidates stay quiet while thinking of a hard solution that doesn't exist, then get frustrated when they find that the easy answer is what I was looking for. On my end, this problem is especially tricky because I don't necessarily want to say that something is a warm-up question.

* I've had candidates who have had trouble because they viewed problems as either too concrete or too open-ended. In some cases, I hope that candidates will notice ambiguities in the problem and ask clarifying questions, or come up with creative alternate solutions. In other cases, I know that a particular high-level structure makes a good, consistent problem, and I want them to follow that structure.

* I've had candidates who have written code that's either too hacky/messy/unpolished or too professional such that it slows them down.

My best advice to interviewers is to be straightforward about expectations and open-minded about what assumptions the candidate might have coming in. For example, these days, I try to explain the code quality balance I'm looking for, something like "I'm looking for reasonably production-quality code that might pass code review, but it's still an interview setting, so it's fine to leave off things like docs and unit tests".

I think my best advice to interviewees is to keep a conversation going and be open about your thought process and your assumptions. If you're interpreting the problem wrong, a reasonable interviewer should be able to notice and correct that. The main failure mode I've seen here is people being hesitant to communicate their thought process or ask clarifying questions, which means the interviewer isn't able to know when the candidate is doing poorly because they've misunderstood the problem.

A_Person · 7 years ago
I'm truly bemused by your response.

First, if you truly believe that the code I showed is "a snippet of code completely made up or taken out of context and then anonymized by renaming variables", I can only say that I don't believe you've ever worked on large codebases. There are millions of lines of code, in hundreds of thousands of application, in dozens of different languages, all over the world, precisely like the snipped I showed. If you've been coding for 20 years, as you say you have, and haven't seen snippets like that on a thousand occasions, you must have worked in very strange environments. If you really want me to, I'll spend 5 minutes and give you multiple links to exactly similar snippets in various large open source projects.

Second, I'm mystified by your comments regarding my trivially simple code question. that "Interviewers come up with their games with their arbitrary rules and a bunch of prejudice about how a good or bad candidate should react".

Wut? Let's make the question even simpler:

    X := Y / Z
Would you not expect an applicant to say, "What if Z is zero?" ? Would you actually expect the candidate to say - quoting you:

"This looks like a snippet of code completely made up or taken out of context and then anonymized by renaming variables. I have no idea what it's supposed to do, I have no idea why I'm looking at it, and I have no fucking idea what you want from me, and I don't play guess-the-rules type of games."

Are you seriously telling me that you'd hire a candidate who said that? Over one who said, "What if Z is zero?" ?

I think one of us is missing something...

Veedrac · 7 years ago
Asking someone to evaluate code that doesn't mean or do anything seems like a very poor idea. 90% of the important questions are whether you're doing the right thing in the first place, not whether you're using the Hot Trick of the Day.
A_Person · 7 years ago
Huh? (1) It's exactly the kind of code that you'll commonly see in a working line of business application. (2) The entire point of my comment is that I dislike hot tricks of the day as interview questions. What "hot trick of the day" do you see in my post?
gav · 7 years ago
> Does anyone take the different approach displayed above?

I do. I find getting people to reason about code is a great method of finding who can program. Given we read a lot more code that we write, it's a critical skill. Often people seem to get hung up on the stylistic issues though and don't recognize obvious bugs.

More importantly, it's code _they_ didn't write, so it removes the natural inclination to be defensive about it.

One time an interviewee told me the problem was that the code was in Java. I told them that the majority of the code we write was in Java (as per the job description). They told me that our best option was to rewrite everything in Ruby.

A_Person · 7 years ago
Wow! That sounds like a fail to me :-)
idontpost · 7 years ago
I hope you're more communicative about what you're asking in person than that one liner you introduced the code with here.

I'd fail your interview just because I don't think about whiteboard code the way I think about production code. Yeah, the variable names and magic numbers are bad practice--but it's on a whiteboard. I'm not going to waste time writing long descriptive names out by hand on a whiteboard or in pseudocode. It would never occur to me, because of the context, that you're asking me to respond like I'm reviewing production code unless you specifically said that.

A_Person · 7 years ago
> I don't think about whiteboard code the way I think about production code.

Isn't that the whole point of an interviewer writing code on the whiteboard? To see how the applicant would view that code if hired to work in the offered position? Why would an interviewer want the applicant to view that code in any other way? Is an interviewer likely to think, "I'll treat the interviewee's comments as if he was just writing the code as a hobby throwaway, nothing to do with the offered position"?

> the variable names and magic numbers are bad practice / but it's on a whiteboard. I'm not going to waste time writing long descriptive names out by hand on a whiteboard

Great! But in my post the interviewer wrote the code on the whiteboard. The interviewer did not ask the interviewee to write any code on the whiteboard. Where did you get the idea that the interviewee was to write on the whiteboard? Software development requires attention to detail, yes?

BerislavLopac · 7 years ago
Well, both types of trees mentioned in the article are just subtypes of graph, which has numerous other subtypes.

I love this sentence from the technical docs of the NetworkX library, for pure surrealism: A lobster is a tree that reduces to a caterpillar when pruning all leaves.

oreganoz · 7 years ago
By that logic, lists are just trees with one child per node. Except graphs are just 2d lists if you define them via an adjacency matrix. So we've come full circle.

But we both know they are not very much alike in practice.

rs86 · 7 years ago
This could benefit greatly from specifying what operations are available for each structure.
emersion · 7 years ago
Damn. Too many javascripts on this page, including Facebook's. I guess I'll pass.