Today we are streaming, +- 20:00 Prague time.
Topics: 2dimensional DP + Redis Sharding implementation on hashslots
Topics: 2dimensional DP + Redis Sharding implementation on hashslots
π₯3
We are doing LeetRooms with friends. This is semi competitive thing, when we select 4 problems and solve with leaderboard, etc
Let's also check the problems during stream really quickly they are not some bullshit, but pretty simple and cover couple of basic leetcode patterns to revise
Let's also check the problems during stream really quickly they are not some bullshit, but pretty simple and cover couple of basic leetcode patterns to revise
β€1π1
Daily
https://leetcode.com/problems/new-21-game/description/?envType=daily-question&envId=2025-08-17
btw, fuck daily today, it is not mid, explanation in the solutions afterwards
#daily
https://leetcode.com/problems/new-21-game/description/?envType=daily-question&envId=2025-08-17
btw, fuck daily today, it is not mid, explanation in the solutions afterwards
#daily
Naive solution:
add the probabilities of all sequences that lead to score <= k.
For that try every possible choice (it has probability {1/ numofchoices} * subproblem's probability.
Dp optimization:
Top-down and bottom up DP is pretty simple, it will optimize Complexity from O(maxPts ^ k) to O(k ^ maxPts). BUT FOR THIS FUCKING MIDDLE IT IS NOT ENOUGH
Sliding window optimization:
You clearly see that at each iteration of score, we are recalculating contiguous subproblems score+1, score + 2, score + 3, ... score + maxPts
The optimization would be to remove this summing, and just use precalculated window of sums (tbh was not able to figure it out on my own)
For that try every possible choice (it has probability {1/ numofchoices} * subproblem's probability.
Dp optimization:
Sliding window optimization:
The optimization would be to remove this summing, and just use precalculated window of sums (tbh was not able to figure it out on my own)
β€3
Yea, it was great Sunday midday, and then you fucking spent 2-3 hours on stupid problem that if somebody even ask during interview - they just don't want hire you
π10β€2π1
Hint:
work with array of numbers. any 2 numbers, perform operation and add result back.
This is backtracking problem
This is backtracking problem
Solution:
Since constraints are low, we can afford exponential complexity
Pick any 2 numbers from input array, any possible operation over these numbers and put it as result back to array.
This way you decreased array size by one, and now you can work with subproblem F(n) = F(n - 1)
In the end, when you have only 1 number left - check that it is 24.00000000X (can be floating as we have division)
Pick any 2 numbers from input array, any possible operation over these numbers and put it as result back to array.
This way you decreased array size by one, and now you can work with subproblem F(n) = F(n - 1)
In the end, when you have only 1 number left - check that it is 24.00000000X (can be floating as we have division)
π2
A bit of punching bag this day, cause it was not the greatest day tbh
π₯9
I noticed, streams are very low traffic-wise so I want to do a poll, what better to stream, cause leetcode is not a priority at the moment, all important stuff is over. If you have any other idea - let me know in comment section
Priority?
Anonymous Poll
22%
keep streaming leetcode
43%
more system design
42%
implementations (POC) of system designs (messenger, trading plat, uber, instagram, etc)
34%
topic based stream (1 topic whole stream by voting) e.g. DP, distributed lock, sharding, etc
24%
doing my projects online (want to do another pet project similar to pet-4-pet.com)
11%
reading / learning on streams some random thing
10%
prioritize high quality videos/articles instead of long streams
34%
solving real interview problems (leaked)
2%
(propose your idea in discussion)
You will be laughing, but this is as precise as fuck according to managers 4 levels above me.
And I am with 2 screensππππ
And I am with 2 screensππππ
Daily
Pretty easy one - go and collect coins!
https://leetcode.com/problems/number-of-zero-filled-subarrays/description/?envType=daily-question&envId=2025-08-19
#daily
Pretty easy one - go and collect coins!
https://leetcode.com/problems/number-of-zero-filled-subarrays/description/?envType=daily-question&envId=2025-08-19
#daily
β€1
The solution is straight forward:
- detect zeros subarray
- count number of contiguous subarrays for this zeros subarray
- add it to answer
To count the number of contiguous subarrays in array - you can apply recursion or come up with the formula (if you play enough you will understand it is arithmetic progression: 5 + 4 + 3 + 2 +1 => n + n-1 + n-2 + n-3 ... => n(n+1)/2
Another way is to inline the arithmetic progression while you go
- count number of contiguous subarrays for this zeros subarray
- add it to answer
To count the number of contiguous subarrays in array - you can apply recursion or come up with the formula (if you play enough you will understand it is arithmetic progression: 5 + 4 + 3 + 2 +1 => n + n-1 + n-2 + n-3 ... => n(n+1)/2
Another way is to inline the arithmetic progression while you go
β€1