Live data from Hacker News

The Programming Interview from Hell

pythonforengineers.com

21–30 of 147 posts

Re: The Programming Interview from Hell

#22
post #13

I interviewed someone who gave responses akin to "I'd Google it." When presssed, he did finally give some reasonable answers. We ended up hiring him, as we'd interviewed 10 other candidates who'd failed at that point. He ended up being a terrible employee. Seriously, when someone asks you the details of a linked list, they're not trying to find out if you will be able to use one specifically on the job. They're tryin…

linked list is not complex for christ sake.

I think the original intent of the linked list question was to see if the candidate knew pointers. Implementing in a non pointer language would be trivial and definitely not complex.

Re: The Programming Interview from Hell

#24
post #9

OK - but here's a genuine problem that came up the other day in my work (reconciling two datasets - we have various many-to-one mappings of ids that we then want to reconcile against each other). I think it's quite a neat computer science/algorithm challenge, so here goes: Write a function which takes as input a list of sets, many of which are not disjoint, but will output a list of sets where all of the non-disjoint…

Your two examples have the same inputs but different outputs if I am reading this right. What did I miss?

Re: The Programming Interview from Hell

#25
post #19
post #9

OK - but here's a genuine problem that came up the other day in my work (reconciling two datasets - we have various many-to-one mappings of ids that we then want to reconcile against each other). I think it's quite a neat computer science/algorithm challenge, so here goes: Write a function which takes as input a list of sets, many of which are not disjoint, but will output a list of sets where all of the non-disjoint…

The standard data structure to look for in this case is the disjoint-set data structure (also called union-find), https://en.wikipedia.org/wiki/Disjoint-set_data_structure . That should make your function fairly easy to implement.

Thanks for that - I'll take a look!

Re: The Programming Interview from Hell

#26
post #9

OK - but here's a genuine problem that came up the other day in my work (reconciling two datasets - we have various many-to-one mappings of ids that we then want to reconcile against each other). I think it's quite a neat computer science/algorithm challenge, so here goes: Write a function which takes as input a list of sets, many of which are not disjoint, but will output a list of sets where all of the non-disjoint…

[deleted]

Re: The Programming Interview from Hell

#27
post #9

OK - but here's a genuine problem that came up the other day in my work (reconciling two datasets - we have various many-to-one mappings of ids that we then want to reconcile against each other). I think it's quite a neat computer science/algorithm challenge, so here goes: Write a function which takes as input a list of sets, many of which are not disjoint, but will output a list of sets where all of the non-disjoint…

I had a similar interview question at Booking.com once. You can solve it in linear time with some extra space (worst case - linear) for two constant-time lookup structures.

Re: The Programming Interview from Hell

#28
post #9

OK - but here's a genuine problem that came up the other day in my work (reconciling two datasets - we have various many-to-one mappings of ids that we then want to reconcile against each other). I think it's quite a neat computer science/algorithm challenge, so here goes: Write a function which takes as input a list of sets, many of which are not disjoint, but will output a list of sets where all of the non-disjoint…

You could just go on merging sets with each other.

For i from 0 to n-1 , find all sets from i+1 to n-1 which have a non empty intersection with set i. Union set i with all those sets and replace i with the union set.

If you use a disjoint set data structure this will be quadratic or O(n^2)

EDIT: On further thought you need to merge from the end and backwards.

Re: The Programming Interview from Hell

#29
I hope I'm past the part of my career where I go on cold job interviews but if I ever had to go on another job hunt, I'd simply announce that I'm a web developer and not a algorithms person and it looks like I might not be the best fit for the position and just see how the interviewers respond.

Anything less than tossing the playbook warrants a gentle suggestion that we shouldn't waste any more time here and why don't we just end the interview. Stand up, shake hands, thank them for their time, and walk out.

Problems in the interview process should be seen as problems with company culture. I used to wonder about how to appropriately answer the question, "which companies are worth working for?" because it seems like you need a lot of time before you can really tell. But once I realized that the interview is just an extension of company culture, it got a lot easier to weigh opportunities.

I mean, obviously, if you need the money you need the money, but developers are hot enough commodities that it doesn't take long before you're entrenched enough to be able to call the shots like that.

Re: The Programming Interview from Hell

#30
post #9

OK - but here's a genuine problem that came up the other day in my work (reconciling two datasets - we have various many-to-one mappings of ids that we then want to reconcile against each other). I think it's quite a neat computer science/algorithm challenge, so here goes: Write a function which takes as input a list of sets, many of which are not disjoint, but will output a list of sets where all of the non-disjoint…

Your two examples have the same inputs but different outputs if I am reading this right. What did I miss?

The second example provides one more input set (8,10). So the first example has only 3 sets as input, the second example has 4 sets.
Post reply on HN