For those who are on the stream:
https://algo.monster/liteproblems/2534
https://algo.monster/liteproblems/2534
from collections import deque
def time_taken_to_cross_the_door(arrival: list[int], state: list[int]) -> list[int]:
entering = deque()
exiting = deque()
doorstate = 0
t = arrival[0]
person = 0
res = [0] * len(arrival)
while person < len(arrival) or entering or exiting:
if person < len(arrival) and t < arrival[person] and len(entering) == len(exiting) == 0:
t = arrival[person]
doorstate = 0
continue
elif person < len(arrival) and t == arrival[person]:
while person < len(arrival) and arrival[person] == t:
if state[person] == 1:
exiting.append(person)
else:
entering.append(person)
person += 1
competitive = len(entering) > 0 and len(exiting) > 0
if not competitive:
if entering:
res[entering.popleft()] = t
doorstate = 1
else:
res[exiting.popleft()] = t
doorstate = 2
else:
if doorstate == 0 or doorstate == 2:
p = exiting.popleft()
res[p] = t
doorstate = 2
elif doorstate == 1:
p = entering.popleft()
res[p] = t
doorstate = 1
t += 1
return res
if __name__ == "__main__":
arrival = [int(x) for x in input().split()]
state = [int(x) for x in input().split()]
res = time_taken_to_cross_the_door(arrival, state)
print(" ".join(map(str, res)))
AlgoMonster
2534. Time Taken to Cross the Door
Coding interviews stressing you out? Get the structure you need to succeed. Get Interview Ready In 6 Weeks.
❤1
andreyka26_se
For those who are on the stream: https://algo.monster/liteproblems/2534 from collections import deque def time_taken_to_cross_the_door(arrival: list[int], state: list[int]) -> list[int]: entering = deque() exiting = deque() doorstate = 0 …
This is the q that was recently asked one guy from here in Bigtech (very famous, but cannot say which one due to nda)
❤1
andreyka26_se
This is the q that was recently asked one guy from here in Bigtech (very famous, but cannot say which one due to nda)
The guy solved it in 25 mins😅😅😅
I did in 1 hour 15 mins
I did in 1 hour 15 mins
❤1
Daily 383d day streak
A bit tough problem, but not enough to be hard, but it has a pattern, so I would still recommend.
https://leetcode.com/problems/lexicographically-smallest-permutation-greater-than-target/description/?envType=daily-question&envId=2026-08-27
#daily #medium #pattern
A bit tough problem, but not enough to be hard, but it has a pattern, so I would still recommend.
https://leetcode.com/problems/lexicographically-smallest-permutation-greater-than-target/description/?envType=daily-question&envId=2026-08-27
#daily #medium #pattern
❤1
andreyka26_se
Video message
Burnout therapy. Just before training I wanted to resign. Now I even want to work a bit.
Lately it was first time for past 8 years (whole career) that I wanted to take vacation.
But I literally cannot, because manager nicely hinted that I should be around due to some important thing, and also I should deliver stuff noone else knows how to deliver on time😅
Lately it was first time for past 8 years (whole career) that I wanted to take vacation.
But I literally cannot, because manager nicely hinted that I should be around due to some important thing, and also I should deliver stuff noone else knows how to deliver on time😅
❤3
andreyka26_se
Burnout therapy. Just before training I wanted to resign. Now I even want to work a bit. Lately it was first time for past 8 years (whole career) that I wanted to take vacation. But I literally cannot, because manager nicely hinted that I should be around…
Remember, if you cannot take single day off, cause there is no one else that can take it over - this is huge redflag.
In Microsoft you can safely die, and it will be alright. Generally there are at least 2 engineers per feature who have knowledge.
In Microsoft you can safely die, and it will be alright. Generally there are at least 2 engineers per feature who have knowledge.
👍9❤1
Daily 384 day streak
For me - seems very complicated and I have to skip such long/hard problems while we are doing Leetcode marathon. But it has pattern, so I cannot say skip, as well as I cannot say musthave.
https://leetcode.com/problems/lexicographically-smallest-palindromic-permutation-greater-than-target/description/?envType=daily-question&envId=2026-08-28
#daily #hard #pattern
For me - seems very complicated and I have to skip such long/hard problems while we are doing Leetcode marathon. But it has pattern, so I cannot say skip, as well as I cannot say musthave.
https://leetcode.com/problems/lexicographically-smallest-palindromic-permutation-greater-than-target/description/?envType=daily-question&envId=2026-08-28
#daily #hard #pattern
❤4
andreyka26_se
10 minutes and we go leetcode marathon
Come and join I will do small announcement, and then leave. I know it is boring to watch somebody struggling with leetcode. So I understand.
It is only for duration of marathon, and then I will switch to regular content: networks, system design and finally will finish Prague -> Dublin relocation
It is only for duration of marathon, and then I will switch to regular content: networks, system design and finally will finish Prague -> Dublin relocation
❤8
andreyka26_se
7/16 https://www.youtube.com/live/0R68bjkv5j4 #leetcode #stream
Almost 4 hours of PURE LEETCODE that has finished (unsuccessfully) with leetcode daily xDDD.
Thanks to all who were with me
Thanks to all who were with me
🤯11🔥1