|
|
|
|
|
by valicord
700 days ago
|
|
At a glance it seems correct, but there's a lot of inefficiencies, which might or might not be acceptable depending on the interview level/role. Major: 1. Sorting finishedPaths is unnecessary given it only asks for the most frequent one (not the top 3 btw) 2. Deleting from the middle of the unfinishedPaths list is slow because it needs to shift the subsequent elements 3. You're storing effectively the same information 3 times in unfinishedPaths ([A, B, C], [B, C], [C]) Minor: 1. line.split is called twice 2. Way too many repeated dict lookups that could be easily avoided (in particular the 'if key (not) in dict: do_something(dict[key])' stuff should be done using dict.get and dict.setdefault instead) 3. deleteIndex doesn't need to be a list, it's always at most 1 element |
|
This is exactly what irritates us about these questions. There's no possible answer that will ever be correct "enough".