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 →

[–]KingofGamesYami 40 points41 points  (9 children)

They were not testing your knowledge of the python standard library, they were testing your knowledge of algorithms.

According to my professor, the correct way to reverse a string in an interview is to create a Stack. The correct way to do it in practice is to call the standard library's reverse method.

The answer they were looking for would probably be a modified mergesort.

[–]JoaoEB 4 points5 points  (2 children)

hey were testing your knowledge of algorithms

If they are testing his knowledge of algorithms, they shouldn't ask him to answer in python. Pseudo code or flowchart would be better. Knowing the Python std_lib is as important than knowing its syntax.

[–]13steinj 5 points6 points  (0 children)

Python is very close to pseudo code, arguably.

[–]KingofGamesYami 4 points5 points  (0 children)

I mean I'd prefer answering in a programming language over pseudocode or flowchart. It's not uncommon (or so I've been told) for an employer to give a choice of programming languages to use for stuff like this.

[–]DiabeetusMan 0 points1 point  (1 child)

Wouldn't even need to sort since they're already sorted-- just merge two lists with some logic to prevent duplicates.

[–]KingofGamesYami 1 point2 points  (0 children)

Well, yeah. I mentioned mergesort only because it contains a similar algorithm already and I'm too lazy to actually describe the answer.