File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change 11class Codec :
22 def __init__ (self ):
3- self .ltos = {}
4- self .stol = {}
3+ self .d = {}
54 self .s = '0123456789qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM'
65
76 def spliturl (self , url ):
@@ -13,7 +12,7 @@ def getshort(self):
1312 short = ""
1413 for i in range (7 ):
1514 short += random .choice (self .s )
16- if short not in self .stol :
15+ if short not in self .d :
1716 return short
1817
1918 return ''
@@ -26,8 +25,7 @@ def encode(self, longUrl):
2625 """
2726 addr , long = self .spliturl (longUrl )
2827 short = self .getshort ()
29- self .stol [short ] = long
30- self .ltos [long ] = short
28+ self .d [short ] = long
3129 return addr + short
3230
3331 def decode (self , shortUrl ):
@@ -37,7 +35,7 @@ def decode(self, shortUrl):
3735 :rtype: str
3836 """
3937 addr , short = self .spliturl (shortUrl )
40- return addr + self .stol [short ]
38+ return addr + self .d [short ]
4139
4240# Your Codec object will be instantiated and called as such:
4341# codec = Codec()
You can’t perform that action at this time.
0 commit comments