|
|
|
|
|
by bonzini
1156 days ago
|
|
To be honest the first solution is literally one line of code. The data structures are those included in Python, there's nothing to look up. It's an important skill to take some code written by others and understand precisely it's performance characteristics. The interview question is not just about knowing data structures and is not about Behdad showing off either. It's the starting point for a Socratic discussion. |
|
OK, but every program is literally one line of code. We only put line breaks in to make them easier to read.
The author makes this terrible comment about his "one-liner":
> Most candidates though write a for loop, which is equally acceptable.
He has also written a for loop. Specifically, he's written this for loop: