mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 20:26:07 -04:00
Update README.md
This commit is contained in:
parent
50878d0b85
commit
a853cb34c5
@ -32,8 +32,8 @@ class RandomizedSet:
|
|||||||
|
|
||||||
def remove(self, val: int) -> bool:
|
def remove(self, val: int) -> bool:
|
||||||
if val in self.dict:
|
if val in self.dict:
|
||||||
index = self.dict[val]
|
last_element, idx = self.set[-1], self.dict[val]
|
||||||
self.set[index] = self.set[-1]
|
self.set[idx], self.dict[last_element] = last_element, idx
|
||||||
self.set.pop()
|
self.set.pop()
|
||||||
del self.dict[val]
|
del self.dict[val]
|
||||||
return True
|
return True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user