Daily (320/373 streak until LC cap)
Easy one for bruteforce, pretty hard for the optimized O(n) solution. But bruteforce will pass here.
https://leetcode.com/problems/count-subarrays-with-majority-element-i/description/?envType=daily-question&envId=2026-06-28
#daily #medium #pattern
Easy one for bruteforce, pretty hard for the optimized O(n) solution. But bruteforce will pass here.
https://leetcode.com/problems/count-subarrays-with-majority-element-i/description/?envType=daily-question&envId=2026-06-28
#daily #medium #pattern
❤1
Daily (322/373 streak until LC cap)
Not bad problem, not that hard, however no pattern.
https://leetcode.com/problems/find-the-maximum-number-of-elements-in-subset/description/?envType=daily-question&envId=2026-06-28
#daily #medium #nopattern
Not bad problem, not that hard, however no pattern.
https://leetcode.com/problems/find-the-maximum-number-of-elements-in-subset/description/?envType=daily-question&envId=2026-06-28
#daily #medium #nopattern
❤1
Daily (323/373 streak until LC cap)
Now today's problem (all previous ones where for my long time away)
This one is pretty easy, I would rate it as easy. Go for it.
https://leetcode.com/problems/maximum-element-after-decreasing-and-rearranging/description/?envType=daily-question&envId=2026-06-28
#daily #medium #nopattern
Now today's problem (all previous ones where for my long time away)
This one is pretty easy, I would rate it as easy. Go for it.
https://leetcode.com/problems/maximum-element-after-decreasing-and-rearranging/description/?envType=daily-question&envId=2026-06-28
#daily #medium #nopattern
❤1
Daily (324/373 streak until LC cap)
Easy if using O(n^2) or built-in function. But pretty tough if using some special algo like KMP.
https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word/description/?envType=daily-question&envId=2026-06-29
#daily #easy #nopattern
Easy if using O(n^2) or built-in function. But pretty tough if using some special algo like KMP.
https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word/description/?envType=daily-question&envId=2026-06-29
#daily #easy #nopattern
❤2
Warm up for Concurrency / Multithreading in System design. Let's say we have plane seat booking system like Kiwi or event booking system like Ticket master.
The domain is simple, multiple users might click on the same seat and double book it. Solution: lock the seat for 10 minutes and allow single user to proceed with payment or timeout before others can lock it as well.
The domain is simple, multiple users might click on the same seat and double book it. Solution: lock the seat for 10 minutes and allow single user to proceed with payment or timeout before others can lock it as well.
🔥5
andreyka26_se
Warm up for Concurrency / Multithreading in System design. Let's say we have plane seat booking system like Kiwi or event booking system like Ticket master. The domain is simple, multiple users might click on the same seat and double book it. Solution: lock…
Will this code lock seat without double booking?
Anonymous Quiz
15%
yes
61%
no, there will be double booking
24%
idk, see answer
❤3
andreyka26_se
Warm up for Concurrency / Multithreading in System design. Let's say we have plane seat booking system like Kiwi or event booking system like Ticket master. The domain is simple, multiple users might click on the same seat and double book it. Solution: lock…
The reason for double booking problem here.
We are assume our backend is multithreaded, however even in single threaded nodejs, the same thing can happen because of different network delays.
- 2 threads read the seat, and see status = "available", which means we can write "reserved".
- both threads are writing 'reserved' and putting their customer that is doing the request.
- you see that red customer2 (red) overrides whatever was written by customer1 (blue). However customer1 (blue) got successful write, no errors, nothing.
We are assume our backend is multithreaded, however even in single threaded nodejs, the same thing can happen because of different network delays.
- 2 threads read the seat, and see status = "available", which means we can write "reserved".
- both threads are writing 'reserved' and putting their customer that is doing the request.
- you see that red customer2 (red) overrides whatever was written by customer1 (blue). However customer1 (blue) got successful write, no errors, nothing.
❤2
andreyka26_se
The reason for double booking problem here. We are assume our backend is multithreaded, however even in single threaded nodejs, the same thing can happen because of different network delays. - 2 threads read the seat, and see status = "available", which…
you might think: yea, just let's do serializable isolation on database (single thread) and single thread of the app (async nodejs for example), and it will work
well.... no it won't.
For one threaded app. We can serially (single threaded manner) send requests to database, but due to I/O asynchrony, we might still end up in situation that both thread1 and thread2 read the data before any of them write anything.
For one threaded storage (can be Redis for example). Since 2 reads will happen before writes -> they will still return available, and then we just sequentially write the data as in the diagram.
So here neither single threaded app, not single threaded storage saves us.
well.... no it won't.
For one threaded app. We can serially (single threaded manner) send requests to database, but due to I/O asynchrony, we might still end up in situation that both thread1 and thread2 read the data before any of them write anything.
For one threaded storage (can be Redis for example). Since 2 reads will happen before writes -> they will still return available, and then we just sequentially write the data as in the diagram.
So here neither single threaded app, not single threaded storage saves us.
❤2
andreyka26_se
you might think: yea, just let's do serializable isolation on database (single thread) and single thread of the app (async nodejs for example), and it will work well.... no it won't. For one threaded app. We can serially (single threaded manner) send requests…
So remember, whenever you have race conditions situation in your system design, blindly "read data by application, make decision in application and then write back to storage" does not work.
You will need to use some additional things to make it work, and we are going to talk about it in the article that currently "work in progress"
You will need to use some additional things to make it work, and we are going to talk about it in the article that currently "work in progress"
👍7🔥2
Daily (325/373 streak until LC cap)
Not bad problem, has well known pattern that I haven't seen for a very long time in daily problems. Definitely recommended. It is not hard
https://leetcode.com/problems/number-of-substrings-containing-all-three-characters/description/?envType=daily-question&envId=2026-06-30
#daily #medium #pattern
Not bad problem, has well known pattern that I haven't seen for a very long time in daily problems. Definitely recommended. It is not hard
https://leetcode.com/problems/number-of-substrings-containing-all-three-characters/description/?envType=daily-question&envId=2026-06-30
#daily #medium #pattern
🔥6
Daily 326 streak
Nice problem, graphs (in some sense), not very very hard, but pretty tough. Recommend, it uses 2 common patterns.
https://leetcode.com/problems/find-the-safest-path-in-a-grid/description/?envType=daily-question&envId=2026-07-01
#daily #medium #pattern
Nice problem, graphs (in some sense), not very very hard, but pretty tough. Recommend, it uses 2 common patterns.
https://leetcode.com/problems/find-the-safest-path-in-a-grid/description/?envType=daily-question&envId=2026-07-01
#daily #medium #pattern
❤2
andreyka26_se
Daily 326 streak Nice problem, graphs (in some sense), not very very hard, but pretty tough. Recommend, it uses 2 common patterns. https://leetcode.com/problems/find-the-safest-path-in-a-grid/description/?envType=daily-question&envId=2026-07-01 #daily #medium…
From now on I switch pattern
Daily (X/373 streak until LC cap) to Daily X streak as we have got cap, and I don't have much goal now except just keep going and keep skill🤯4🔥1
Feel sorry for overheated EU, but here it is cold enough to make me wear jacket at night, now 17 degrees + wind. Amazing summer, love it in Dublin
❤5
Daily 327th day streak
Exactly same pattern as was yesterday, just a bit different problem semantics. Definitely worth of recalling the patterns, as they are used in the interviews.
https://leetcode.com/problems/find-a-safe-walk-through-a-grid/description/?envType=daily-question&envId=2026-07-02
#daily #medium #pattern
Exactly same pattern as was yesterday, just a bit different problem semantics. Definitely worth of recalling the patterns, as they are used in the interviews.
https://leetcode.com/problems/find-a-safe-walk-through-a-grid/description/?envType=daily-question&envId=2026-07-02
#daily #medium #pattern
❤3
andreyka26_se
Just checking if it is me who didn't know, or it is for majority of the people
this is one of bunch of interesting things that are used in my current project in a very tricky manner, by ex-googlers.
I now have exactly same vibe/feeling as I had at my first company (2018, small 60 people outsource company), where I had techlead with 10+ years of experience, with already rejected Amazon and Microsoft offers: everything looks unknown and/or complicated, you overloading your brain with a lot of stuff that you are supposed to know. Understanding that people around are quite fluent in in it comparing to you hurts even more.
I now have exactly same vibe/feeling as I had at my first company (2018, small 60 people outsource company), where I had techlead with 10+ years of experience, with already rejected Amazon and Microsoft offers: everything looks unknown and/or complicated, you overloading your brain with a lot of stuff that you are supposed to know. Understanding that people around are quite fluent in in it comparing to you hurts even more.
👍4