题目:

题解:
class Codec:
def __init__(self):
self.dataBase = {}
def encode(self, longUrl: str) -> str:
while True:
key = randrange(maxsize)
if key not in self.dataBase:
self.dataBase[key] = longUrl
return "http://tinyurl.com/" + str(key)
def decode(self, shortUrl: str) -> str:
i = shortUrl.rfind('/')
key = int(shortUrl[i + 1:])
return self.dataBase[key]

被折叠的 条评论
为什么被折叠?



