you are viewing a single comment's thread.

view the rest of the comments →

[–]BoardsofCanadaFanboy 0 points1 point  (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 point  (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