LOVE BABBAR 450 questions series

Part 25 is uploaded guys.
We have completed strings.
Thanks for sticking around so far.
Please continue to do so.
Like, share and subscribe.

Hats off to your dedication man. Like this, you will complete all 450 problems within 1-2 months along with helping others. Really appreciate your good work.

1 Like

Thanks a lot brother.
Please share the channel with all your friends and subscribe to the channel.
It will really motivate me.
All the best for your future endeavour.

1 Like

Check out this small announcement and be supportive.
It will help me grow and also benefit you all in one way or the other.

My google kickstart round H.
Not satisfied but got best rank till date.

If you have upsolved 2nd problem for full points, please make a video on that. I really like your way of explanations.

I shall definitely try very soon.

1 Like

You can just calculate all the boring numbers till (and including) R and similarly till L and subtract them.
To calculate all boring numbers till X (say)-
Iterate through 1 to len(X)-1.
If i is the curr length, then the count of boring numbers of that length can be given by 5^i because each place has 5 options.
Now tough task is to count the boring numbers of length len(X). Now we have an upper bound of X.
Now we’ll iterate through each digit of X from left to right. Say we encounter the first digit as 5. If we choose 5 at first position, we will have restrictions on the next positions. So, for the time being I only consider odd values less than 5. Say, that equals to val. So, count of boring numbers with the first position less than 5 and odd can be calculated as (5^{l-1} \cdot val) if l is the length of the X. Now consider fixing the first number as 5 and repeat the same procedure for next digits.
Just as an example to make clear. Say the number is something like 56....
We fix 5 now number of choices of first place is 1, for second place is 3 (0,2,4) and for the rest of l-2 places we have 5 choices without restrictions and in next iteration we’ll fix 6 and so on…
One thing more, Say we get a number like 57... Since second place is 7 and we want it to be even, we will not calculate the second part of answer by fixing 7 and will break the loop.

Code Snippet
b=len(r) # r is any number in its string format and b is length of the string
for i in r:
    for j in range(int(i)-1,-1,-1):
        if j%2==c:
    if int(i)%2!=c%2:
1 Like

Don’t we require digit dp for full points?

Sorry, I don’t know what digit dp actually is. My solution is O(length) where length can be at max 18. I just used simple rule of product in combo.

Part 26 is uploaded
sorting and searching has started.
Like share and subscribe.

Thank you all.
Share the channel with all your friends.
Subscribe if you have not yet!.

Part 27 is uploaded.
Try to code the last problem by yourself first and then check my solution for reference.
Like,share and subscribe.

Part 28 is uploaded.
Last problem has 6 different approaches.
I suggest you to go and find out atleast 2 to 3 more.
Like, share and subscribe.

Please watch this video and tell me if their is a logical approach and an ideal one.

Part 29 is uploaded.
First question is asked in interviews frequently.
That’s what everyone says.
Check it out!.
Like share and subscribe.

Part 30 is uploaded.
Try the homework problem by referring to the easier version of the same concept(2sum,3sum)
Like share and subscribe.

Part 31 is uploaded.
For the last problem i shall tell the O(1) space approach in the next video.
Like share and subscribe.

Part 32 is uploaded.
Watch the video that i have mentioned in the description box.
Like share and subscribe.

Part 33 is uploaded.
You should know how to implement certain functions without STL.
IN Interviews(technical) it will help you a lot.
Like share and subscribe.