Skip to content

Commit 722f520

Browse files
committed
weeklyprem
1 parent 4688ceb commit 722f520

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

my-submissions/m1756 v1.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class MRUQueue:
2+
3+
def __init__(self, n: int):
4+
self.q = list(range(1, n + 1))
5+
6+
def fetch(self, k: int) -> int:
7+
self.q.append(self.q.pop(k - 1))
8+
return self.q[-1]
9+
10+
11+
# Your MRUQueue object will be instantiated and called as such:
12+
# obj = MRUQueue(n)
13+
# param_1 = obj.fetch(k)

my-submissions/m1756.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
### Version 1
2+
3+
This version does not implement the followup to reduce the O(n) complexity of `fetch()`.
4+
This will require following up to adjust in the future.

0 commit comments

Comments
 (0)