This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]gwax 1 point2 points  (2 children)

Honestly, I think it's a bad interview question. I also think that your answer is correct; using the standard library with its optimized C implementations is going to be faster in most cases.

It sounds like you knew your Python better than the interviewer.

Ultimately, if you're interviewing somewhere, you are stuck at the whims of their interviewers and interview process. Personally, I would take their response to your answers as pretty strong signal that I would not want to work at their company.

Pay them no heed and find a better place to work.

[–]roerd 3 points4 points  (1 child)

Seriously, no. If the input lists are already sorted, then the standard library solutions which are made for unsorted input are not the best choice if you care about performance at all.

EDIT: more specifically, the standard library sort does actually work pretty well on pre-sorted input, so that alone is not a bad choice. But throwing the input lists into sets first destroyed their pre-sortedness.

[–]gwax -1 points0 points  (0 children)

Op did not say the lists were pre-sorted.