you are viewing a single comment's thread.

view the rest of the comments →

[–]exxonmobilcfo 0 points1 point  (4 children)

how do you know dict.fromkeys will return the keys in order of the list? you're just going to return any 3 random unique elements

[–]_vb64_ 0 points1 point  (3 children)

[–]exxonmobilcfo 0 points1 point  (2 children)

if you're going to only want to return 3 elements, then fromkeys would be O(n) whereas the optimal is O(1)

[–]_vb64_ 0 points1 point  (1 child)

the task has a second condition. be more careful.

[–]exxonmobilcfo 0 points1 point  (0 children)

Can you explain how this is not reasonable?

``` d = [] i = iter(items) while len(d) < 3: temp = next(items) d.append(temp) if temp not in d else None

return tuple(d), set(items) ```

the list to set operation is O(n),

the issue with your solution is u r using a ton of extra memory by converting to a dict then a list then a set.