collectUsed collect(LRU) collectcache. collectIt collectshould collectsupport collectthe collectfollowing collectoperations: collectget collectand collectput. get(key) collect- collectGet collectthe collectvalue collect(will collectalways collectbe collectpositive) collectof collectthe collectkey collectif collectthe collectkey collectexists collectin collectthe collectcache, collectotherwise collectreturn collect-1. put(key, collectvalue) collect- collectSet collector collectinsert collectthe collectvalue collectif collectthe collectkey collectis collectnot collectalready collectpresent. collectWhen collectthe collectcache collectreached collectits collectcapacity, collectit collectshould collectinvalidate collectthe collect least collectrecently collectused collectitem collectbefore collectinserting collecta collectnew collectitem. The collectcache collectis collectinitialized collectwith collecta collectpositive collectcapacity. Follow up: Could collectyou collectdo collectboth collectoperations collectin collectO(1) collecttime collectcomplexity? class collectLRUCache: collect collect collect collectdef collect__init__(self, collectcapacity: collectint) collect collect collect collectdef collectget(self, collectkey: collectint) collect-> collectint:: collect collect collect collectdef collectput(self, collectkey: collectint, collectvalue: collectint) collect-> collectNone: Example: LRUCache collectcache collect= collectnew collectLRUCache( collect2 collect/* collectcapacity collect*/ collect); cache.put(1, collect1); cache.put(2, collect2); cache.get(1); collect collect collect collect collect collect collect// collectreturns collect1 cache.put(3, collect3); collect collect collect collect// collectevicts collectkey collect2 cache.get(2); collect collect collect collect collect collect collect// collectreturns collect-1 collect(not collectfound) cache.put(4, collect4); collect collect collect collect// collectevicts collectkey collect1 cache.get(1); collect collect collect collect collect collect collect// collectreturns collect-1 collect(not collectfound) cache.get(3); collect collect collect collect collect collect collect// collectreturns collect3 cache.get(4); collect collect collect collect collect collect collect// collectreturns collect4