kartik8800's blog

By kartik8800, history, 4 years ago, In English

Hello Codeforces!

This series of videos are focused on explaining dynamic programming by illustrating the application of digit DP through the use of selected problems from platforms like Codeforces, Codechef, SPOJ, CSES and Atcoder.

After going through this series, you should find yourself confident in solving problems which require the use of digit dp and also implementing them in a reasonable amount of time.

I will also live code and submit the solutions to the problem on the coding platform from where the problem comes.

Some Basic elements of Dynamic Programming

Some general ideas and my thoughts about DP to help you get started:

Part 1: https://youtu.be/24hk2qW_BCU
1. What is Divide and Conquer?
2. What is Dynamic Programming?
3. Types of DP problems.

Part 2: https://youtu.be/yfgKw6BUZUk
1. What is a DP-state?
2. Characterizing a DP-state.
3. What is a recurrence?
4. Top Down v/s Bottom Up.

Part 3: https://youtu.be/X-3HklSPx6k
1. Directed Acyclic Graph(DAG) Representation of DP solution
2. Visualizing Top-Down and Bottom-Up.
3. Evaluation order for bottom-up codes.
4. Analyzing the space and time complexity for a DP solution(derivation).

You may also want to checkout these video tutorials:
- Beginner Friendly Series on Dynamic Programming
- Dynamic Programming on Trees
- Introduction to DP with Bitmasking

Introduction to Digit DP

I discuss the following concepts in this video:

  1. What exactly is Digit DP?
  2. What are the types of problems I can solve with Digit DP?
  3. Discussing a sample problem and it's brute force solution.
  4. Building up an intuition towards a DP based solution.
  5. Further discussing another concept required for solving Digit DP problems.
  6. Coding the solution which we came up with.

video link: https://youtu.be/heUFId6Qd1A

Google Kick Start Round H 2020: Boring Numbers

I'll discuss a problem named boring numbers that comes from a Google kick start round.
Problem link: google kick start problem
Solution: https://youtu.be/2yAEj-0A8bk

SPOJ: Digit Sum

Problem link: https://www.codechef.com/problems/ENCODING
Solution: https://www.youtube.com/watch?v=H6OCV7qcZoQ

Codechef long: Encoding

Problem link: https://www.spoj.com/problems/PR003004/
Solution: https://youtu.be/B7ZWUBfaIq0

CSES: Counting Numbers

Problem link: https://cses.fi/problemset/task/2220
Solution: https://youtu.be/lD_irvBkeOk

Practice Problems:
1. https://www.spoj.com/problems/CPCRC1C/
2. https://www.spoj.com/problems/NUMTSN/
3. https://www.spoj.com/problems/PR003004/
4. https://mirror.codeforces.com/contest/628/problem/D
5. https://mirror.codeforces.com/gym/100886/problem/G

Will be adding more videos soon!
Hope people find this helpful :)

UPD: added spoj digit sum and codechef enocding. This is the last video for this series(at least for now) unless there are many people who want more.
UPD: added solution to standard digit dp problem from CSES, namely counting numbers.

  • Vote: I like it
  • +66
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
  Vote: I like it +1 Vote: I do not like it

Good article bro, keep it up

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by kartik8800 (previous revision, new revision, compare).

  • »
    »
    4 years ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    you seem to be good at dp.. I had even watched your atCoder series in Coding Blocks... Keep up

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by kartik8800 (previous revision, new revision, compare).

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by kartik8800 (previous revision, new revision, compare).

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I am not able to understand the leading zero logic from the yt video. Could someone help me with the understanding ?

  • »
    »
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Yes, the leading zero only checks whether the preceding digit we took is leading zero or not;

    int helper(string& num , int n , int predigit , bool leading_zero , bool tight){

    for(int digit = 0; digit <= limit ; digit++){
    
             if(digit == predigit && leading_zero == 0) continue;
    
               ans +=  helper(num , n-1 , digit , (leading_zero && digit == 0) , (tight && (digit == limit)));
    
             }

    in this code if leading_zero is 1 and also digit == 0 then (leading_zero && digit == 0) --> it pass 1 in next recursive call and then if in next recursive call leading_zero is 1 then we know that previous digit is leading zero;