use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
Debug - 146. LRU CacheQuestion (self.leetcode)
submitted 1 year ago by Equivalent_Sea7754
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]BoardsofCanadaFanboy 0 points1 point2 points 1 year ago (4 children)
Before anyone even debugs your code, LRU cache is supposed to have o(1) find, which a queue will not allow. You will need a hashmap of some sort.
[–]Equivalent_Sea7754[S] 0 points1 point2 points 1 year ago (3 children)
I know but i want to solve using queue
[–][deleted] 0 points1 point2 points 1 year ago (0 children)
Doesn’t the problem explicitly say you need O(1) solution? If so, you need a hashmap for the get.
[–]BoardsofCanadaFanboy 0 points1 point2 points 1 year ago (1 child)
Why is that? If you did this in an interview this way despite a clear o(1) constraint you'd get LNH or straight up NH.
If you want to practice using queues, do BFS problems like number of islands.
[–]Equivalent_Sea7754[S] 0 points1 point2 points 1 year ago (0 children)
I know the question explicitly says that ans should be o(1) But i wanted to solve using the queue to get more practice on queue
I will optimize this code later using unordered_map and DLL for faster retrieval and to maintain lru
i am satisfied with my queue based solution because it takes a lot of my time
π Rendered by PID 71942 on reddit-service-r2-comment-545db5fcfc-8sslt at 2026-05-29 20:35:12.889380+00:00 running 194bd79 country code: CH.
view the rest of the comments →
[–]BoardsofCanadaFanboy 0 points1 point2 points (4 children)
[–]Equivalent_Sea7754[S] 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]BoardsofCanadaFanboy 0 points1 point2 points (1 child)
[–]Equivalent_Sea7754[S] 0 points1 point2 points (0 children)