CSES DP: Counting Numbers

CSES problem Counting Numbers: cses.fi/problemset/task/2220/
The problem is a standard digit dp problem and I recommend watching introduction to digit dp before watching this video.
Introduction to Digit Dynamic Programming
Introduction to Digit Dynamic Programming: • Introduction to Digit ...
Timestamps:
0:00 Introduction
0:45 problem statement
2:00 Brute force solution
2:35 Breaking the problem into easier problem
3:15 solving for range [0,b]
13:00 implementation
22:00 debugging
25:55 more debugging
26:10 eureka moment
27:15 rider provider AC
Super useful books for algo ds and programming fundamentals!
1. Introduction to Algorithms by Cormen: amzn.to/35AmQqu
2. The Algorithm Design Manual: amzn.to/2K9RGPq
3. Fundamentals of Data Structures in C++: amzn.to/2LCwIsN
4. Object-Oriented Programming by E Balagurusamy: amzn.to/2Xxmdtr
5. Head First Java: amzn.to/39kb44K
6. Cracking the coding interview: amzn.to/3iDOHLK
7. Database System concepts: amzn.to/3pisuFQ
8. Operating Systems: amzn.to/39fcmis
9. Discrete Mathematics: amzn.to/2MlgCE6
10. Compiler Design: amzn.to/3pkYvx2

Пікірлер: 53

  • @em_nikhil_007
    @em_nikhil_0073 жыл бұрын

    Asli content iss channel pe hai , baaki sab roadmap bana rhe 😂😂

  • @DebojyotiMandal

    @DebojyotiMandal

    3 жыл бұрын

    @Mathew Jakob But it is asking 10 dollar

  • @DebojyotiMandal
    @DebojyotiMandal3 жыл бұрын

    This is how I mastered digit dp by seeing ur playlist ! You are a gem brother. Make cses graph plz

  • @hymnish_you
    @hymnish_you2 жыл бұрын

    I dont have words to express how beautiful your explanations are. Thanks!

  • @Avinash-qf8ez
    @Avinash-qf8ez Жыл бұрын

    Thanks! For this valuable and amazing digit dp series.... No words man.

  • @ankushgupta2528
    @ankushgupta25283 жыл бұрын

    The zinger in beginning made me go "oh no he diidddn't" , great stuff!!

  • @harrisondong5405
    @harrisondong54052 жыл бұрын

    Thanks guy, your explanation is very clear and useful.

  • @VikashKumarthakur-bo6jq
    @VikashKumarthakur-bo6jqАй бұрын

    whatever i learn from u i feel like mastered that topics..great content thanks a lot

  • @VikashKumarthakur-bo6jq

    @VikashKumarthakur-bo6jq

    Ай бұрын

    I know it's hard time consuming to provide such lvl of quality of content if u can plz do us ..lots of us get benifits thanks

  • @Nilesh-xd4ux
    @Nilesh-xd4ux Жыл бұрын

    Nice explaination I solved Cses and Kickstart myself after watching your two videos

  • @sarthaksharma6973
    @sarthaksharma6973 Жыл бұрын

    You never waste our time sir by debugging. This actually reflects how hard it is to arrive at a solution even if you have already solved the problem. True gem.

  • @PikasoCapture

    @PikasoCapture

    Жыл бұрын

    trueeeeeeeeeeeeeeeeeeeeeeeee

  • @rakeshswami9848
    @rakeshswami9848Ай бұрын

    Hey bhiya only see your first video of digit dp series and able to solve remaing 4 by myself you are the god of CP❤.

  • @AlgosWithKartik

    @AlgosWithKartik

    Ай бұрын

    Thankyou! Keep it up :)

  • @anshusingh2473
    @anshusingh24733 жыл бұрын

    thanks for Digit Dp series

  • @fuadalhasan1784
    @fuadalhasan1784 Жыл бұрын

    great explanation .. thanks a lot.

  • @shristip519
    @shristip5193 жыл бұрын

    My sister watches Prita Arora and Pragya Arora. I watch Kartik Arora 😎

  • @AlgosWithKartik

    @AlgosWithKartik

    3 жыл бұрын

    Hahaha xD

  • @amishadixit5157
    @amishadixit51579 ай бұрын

    beautiful explanation sir 💫

  • @Om754
    @Om75411 ай бұрын

    thx

  • @kartikmahajan4405
    @kartikmahajan44053 жыл бұрын

    Dont' you think we need to use logical and(&&) instead of bitwise &? Can you explain why bitwise and(&) is used in your code?

  • @anshusingh2473
    @anshusingh24733 жыл бұрын

    please make one more video for Elevator Rides cses

  • @prasantkumar32
    @prasantkumar323 жыл бұрын

    App bhi roadmap bna do dusre youtubers ke liye🤣🤣🤣

  • @AlgosWithKartik

    @AlgosWithKartik

    3 жыл бұрын

    Yahi krrna padega xD

  • @bloodbath3658
    @bloodbath36583 жыл бұрын

    Hey I have a doubt. Do order of dependencies in which we write dp state matter like dp[a][b][c] it can be written as dp[c][b][a] right because its a function as such so the only thing that should matter is how we are looping through this during iterative dp process according to our formula right like if we have dp[i][j] it will be incorrect to loop through j first then inside that loop we loop through i?

  • @AlgosWithKartik

    @AlgosWithKartik

    3 жыл бұрын

    as per my understanding order of variables do not matter as long as you write the correct recurrence. So if I choose dp[leading_zeros][num_of_digs][tight] and you choose dp[num_of_digs][tight][leading_zeros] as your state we both will get correct answers but different recurrences.

  • @bloodbath3658

    @bloodbath3658

    3 жыл бұрын

    @@AlgosWithKartik Thanks

  • @sachinsingh1956
    @sachinsingh19563 жыл бұрын

    Bhaiya , Your explanation very good. But I have a query that if x == -1 , then there can be a chance that Following statement gives us (dp[n][x][leading_zeros][tight] = ans ) segmentation fault. But bhaiya , in your code there is no segmentation fault occur how it can be happen.

  • @AlgosWithKartik

    @AlgosWithKartik

    3 жыл бұрын

    Yes you are right. The (x==-1) condition should be handled properly by either making x initially equal to 10 instead of -1 or by adding required if statements. Why did my code not fail? I got lucky xD can add a plausible reason for why the code didn't fail if you want. Thanks for pointing out :)

  • @Astrrick
    @Astrrick2 жыл бұрын

    Let us begin with a positive integer N and find the smallest positive integer which doesn't divide N. If we repeat the procedure with the resulting number, then again with the new result and so on, we will eventually obtain the number 2 (two). Let us define strength(N) as the length of the resulting sequence. For example, for N = 6 we obtain the sequence 6, 4, 3, 2 which consists of 4 numbers, thus strength(6) = 4. Given two positive integers A 1=

  • @sg1192k
    @sg1192k3 жыл бұрын

    Windows 7--> Windows 10 nice upgrade :P

  • @artbrare
    @artbrare Жыл бұрын

    why do we start with leading_zeros = 1?

  • @amandixit3555
    @amandixit35553 жыл бұрын

    Bhaiya how to Approach this problem count of numbers with sum of digits as s and length n

  • @AlgosWithKartik

    @AlgosWithKartik

    3 жыл бұрын

    Try digit dp playlist!

  • @ankitpandey3724
    @ankitpandey37243 жыл бұрын

    Roadmap videos 😂😂... Am a rider provider 🔥🔥🔥🔥🔥

  • @AlgosWithKartik

    @AlgosWithKartik

    3 жыл бұрын

    Rider OP

  • @AshwaniKumar-tw8vp
    @AshwaniKumar-tw8vp3 жыл бұрын

    99th like

  • @em_nikhil_007
    @em_nikhil_0073 жыл бұрын

    bhaiya graph series bhool gye kya 😅😅

  • @AlgosWithKartik

    @AlgosWithKartik

    3 жыл бұрын

    Mehnat aur time lgega kaafi Try krrta hu varna Roadmap banadunga graphs ke liye xDD On a serious note if I feel I might not be able to cover it at a good pace I'll compile some useful resources and share with you all :) I think Demoralizer made a short course with unacademy on the same

  • @em_nikhil_007

    @em_nikhil_007

    3 жыл бұрын

    @@AlgosWithKartik haha.. ye bhi theek hai.

  • @bloodbath3658

    @bloodbath3658

    3 жыл бұрын

    @@AlgosWithKartik hey can you just make videos of the CSES RMQ query questions you already made a blog on it but it will be easier now plus your video explanations are godlevel 😅😜...I think dardev already made graph cses editorial video playlist which is also really good so it will be redundant to make graph series now but yeah if you were planning to solve other questions feel free to do whatever you like Cheers

  • @bloodbath3658

    @bloodbath3658

    3 жыл бұрын

    @@AlgosWithKartik I am still going through your dp playlist but i haven't seen Sum Over Subset Dp ? Idk maybe you have a video 🤣 lemme finish this playlist first

  • @AlgosWithKartik

    @AlgosWithKartik

    3 жыл бұрын

    @@bloodbath3658 enjoy watching! also I don't have a tutorial on SOS dp but I can recommend a superb CF blog for learning the same: codeforces.com/blog/entry/45223

  • @Jerry-fy2gc
    @Jerry-fy2gc2 жыл бұрын

    I always missed leading zero concepts.

  • @tekbssync5727
    @tekbssync57273 жыл бұрын

    27:16 ye kya hai yrr ... 😂 , thoda sa ending gaana wagera edit kar liya karo bhai , don't be lazy

  • @AlgosWithKartik

    @AlgosWithKartik

    3 жыл бұрын

    Aalsi KZreadr OP