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
Asli content iss channel pe hai , baaki sab roadmap bana rhe 😂😂
@DebojyotiMandal
3 жыл бұрын
@Mathew Jakob But it is asking 10 dollar
This is how I mastered digit dp by seeing ur playlist ! You are a gem brother. Make cses graph plz
I dont have words to express how beautiful your explanations are. Thanks!
Thanks! For this valuable and amazing digit dp series.... No words man.
The zinger in beginning made me go "oh no he diidddn't" , great stuff!!
Thanks guy, your explanation is very clear and useful.
whatever i learn from u i feel like mastered that topics..great content thanks a lot
@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
Nice explaination I solved Cses and Kickstart myself after watching your two videos
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
Жыл бұрын
trueeeeeeeeeeeeeeeeeeeeeeeee
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
Ай бұрын
Thankyou! Keep it up :)
thanks for Digit Dp series
great explanation .. thanks a lot.
My sister watches Prita Arora and Pragya Arora. I watch Kartik Arora 😎
@AlgosWithKartik
3 жыл бұрын
Hahaha xD
beautiful explanation sir 💫
thx
Dont' you think we need to use logical and(&&) instead of bitwise &? Can you explain why bitwise and(&) is used in your code?
please make one more video for Elevator Rides cses
App bhi roadmap bna do dusre youtubers ke liye🤣🤣🤣
@AlgosWithKartik
3 жыл бұрын
Yahi krrna padega xD
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
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
3 жыл бұрын
@@AlgosWithKartik Thanks
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
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 :)
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=
Windows 7--> Windows 10 nice upgrade :P
why do we start with leading_zeros = 1?
Bhaiya how to Approach this problem count of numbers with sum of digits as s and length n
@AlgosWithKartik
3 жыл бұрын
Try digit dp playlist!
Roadmap videos 😂😂... Am a rider provider 🔥🔥🔥🔥🔥
@AlgosWithKartik
3 жыл бұрын
Rider OP
99th like
bhaiya graph series bhool gye kya 😅😅
@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
3 жыл бұрын
@@AlgosWithKartik haha.. ye bhi theek hai.
@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
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
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
I always missed leading zero concepts.
27:16 ye kya hai yrr ... 😂 , thoda sa ending gaana wagera edit kar liya karo bhai , don't be lazy
@AlgosWithKartik
3 жыл бұрын
Aalsi KZreadr OP