I have a list that I keep ordered with bisect with each insertion. When I insort with bisect
[1, 3, 5] # inserting 3
becomes
[1, 3, 3, 5]
But I want bisect to check if a number is found, if it exists don't duplicate it. Cancel the insertion. Is this thing achievable ? I checked the docs and google but the answer eluded me. Thanks in advance.
Note: I do not what to check the list before to see if the element is there, which would increase the complexity. I am trying to get this done without causing that.