Skip to content

Commit 50b59e0

Browse files
committed
Runtime: 841 ms (Top 10.38%) | Memory: 24.8 MB (Top 56.73%)
1 parent 4e2f654 commit 50b59e0

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Runtime: 841 ms (Top 10.38%) | Memory: 24.8 MB (Top 56.73%)
12
class Solution:
23

34
def __init__(self, n: int, blacklist: List[int]):
@@ -7,18 +8,16 @@ def __init__(self, n: int, blacklist: List[int]):
78
self.length=n-len(blacklist)
89
flag=n-1
910
for b in blacklist:
10-
if b<self.length:
11+
if b<self.length:
1112
while flag in self.hashmap:
1213
flag-=1
1314
self.hashmap[b]=flag
1415
flag-=1
15-
16+
1617
def pick(self) -> int:
1718
seed=random.randrange(self.length)
1819
return self.hashmap.get(seed,seed)
19-
20-
2120

2221
# Your Solution object will be instantiated and called as such:
2322
# obj = Solution(n, blacklist)
24-
# param_1 = obj.pick()
23+
# param_1 = obj.pick()

0 commit comments

Comments
 (0)