DEV Community

Discussion on: Day-19 Third Maximum Number

Collapse
 
mridubhatnagar profile image
Mridu Bhatnagar • Edited

This also would would work. The only difference being instead of converting the list to set. You are converting it to a dict. A dict would gain give unique elements. And converting this dict back to list. As long as you have got unique elements in the list. Remove would work as expected.

One could either do these conversions and built-in methods. Or follow the way I have mentioned in the write-up. All possible solutions work and have time complexity O(n).