Digit DP
I didn\'t get any soln in discuss that contains digit dp in python so I did this In this soln, to see whether any digit repeated or not, i take a memo , i guess
I didn\'t get any soln in discuss that contains digit dp in python so I did this In this soln, to see whether any digit repeated or not, i take a memo , i guess you have used it before if not then see following problem it just contain 1 for integer if it\'s already taken otherwise 0 and put it in binary form . Ya it\'s 5 order dp so don\'t be confused i just used it for memoization. if you don\'t know more about digit dp, I will highly recommend you to see kartik arora\'s digit dp video on youtube.\n\n```\nclass Solution:\n    def numDupDigitsAtMostN(self, n: int) -> int:\n        dp=[[[[[-1 for tight in range(2)] for i in range(2)] for i in range(2)] for i in range(2**10)] for i in range(10)]\n        len1 = len(str(n))\n        def fun(i,check,tight,memo,leading_zero):\n            if i==len1:\n                if check==1:\n                    return 1\n                return 0\n            end = 9\n            if dp[i][memo][check][leading_zero][tight]!=-1:\n                return dp[i][memo][check][leading_zero][tight]\n            if tight==1:\n                end = int(str(n)[i])\n            res = 0\n            for j in range(end+1):\n                if j==0 and leading_zero==1:\n                    res+=fun(i+1,0,tight&(j==end),memo,1)\n                    continue\n                if check==1:\n                    res+=fun(i+1,1,tight&(j==end),memo|(1<<j),0)\n                    continue\n                if memo&(1<<j):\n                    res+=fun(i+1,1,tight&(j==end),memo,0)\n                else:\n                    res+=fun(i+1,0,tight&(j==end),memo|(1<<j),0)\n            dp[i][memo][check][leading_zero][tight] = res\n            return res\n        return fun(0,0,1,0,1)
['Python']