Python: Finding Lowest Unique Integer From List
I am trying to find out lowest unique element from list. I have been able to generate O(n^2) and O(n) solutions. But I don't find them optimized. Kindly help me understand,if there
Solution 1:
I can't really comment on the big-O since it depends on the implementation of the built-in python functions which I've never looked into. Here's a more reasonable implementation though:
def lowestUnique(array):
for element in sorted(list(set(array))):
if array.count(element) == 1:
return element
raise Exception('No unique elements found.')
Post a Comment for "Python: Finding Lowest Unique Integer From List"