question_slug
stringlengths
3
77
title
stringlengths
1
183
slug
stringlengths
12
45
summary
stringlengths
1
160
⌀
author
stringlengths
2
30
certification
stringclasses
2 values
created_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
updated_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
hit_count
int64
0
10.6M
has_video
bool
2 classes
content
stringlengths
4
576k
upvotes
int64
0
11.5k
downvotes
int64
0
358
tags
stringlengths
2
193
comments
int64
0
2.56k
numbers-with-repeated-digits
[Java/Python] Count the Number Without Repeated Digit
javapython-count-the-number-without-repe-t5eq
Intuition\nCount res the Number Without Repeated Digit\nThen the number with repeated digits = N - res\n\nSimilar as\n788. Rotated Digits\n902. Numbers At Most
lee215
NORMAL
2019-03-17T04:01:15.508536+00:00
2022-08-14T16:09:31.264170+00:00
32,461
false
# **Intuition**\nCount `res` the Number Without Repeated Digit\nThen the number with repeated digits = N - res\n\nSimilar as\n788. Rotated Digits\n902. Numbers At Most N Given Digit Set\n\n\n# **Explanation**:\n\n1. Transform `N + 1` to arrayList\n2. Count the number with digits < n\n3. Count the number with same prefi...
278
9
['Python', 'Java']
49
numbers-with-repeated-digits
Share my O(logN) C++ DP solution with proof and explanation
share-my-ologn-c-dp-solution-with-proof-6tkio
---\n## 1. Problem\n\n---\nGiven a positive integer N, return the number of positive integers less than or equal to N that have at least 1 repeated digit.\n\nEx
kjer
NORMAL
2019-03-19T07:52:55.595189+00:00
2019-03-19T07:52:55.595234+00:00
8,878
false
---\n## 1. Problem\n\n---\nGiven a positive integer ```N```, return the number of positive integers less than or equal to ```N``` that have at least 1 repeated digit.\n\n**Example 1:**\n```\nInput: 20\nOutput: 1\nExplanation: The only positive number (<= 20) with at least 1 repeated digit is 11.\n```\n\n**Example 2:**\...
184
2
['Math', 'Dynamic Programming', 'Recursion', 'C++']
13
numbers-with-repeated-digits
Python O(logN) solution with clear explanation
python-ologn-solution-with-clear-explana-zabx
The number of non-repeated digits can be easily calculated with permutaiton. We only need to exclude all the non-repeated digits to get the answer.\n\nLet\'s fi
heqingy
NORMAL
2019-03-17T05:55:53.394700+00:00
2019-03-17T05:55:53.394754+00:00
7,169
false
The number of non-repeated digits can be easily calculated with permutaiton. We only need to exclude all the non-repeated digits to get the answer.\n\nLet\'s first consider about the cases where N=10^k\n**N=10**\nthe free digits are marked as `*`, so we only need to consider about `*` and `1*`\n* `*`: obviously all 1-d...
98
1
[]
10
numbers-with-repeated-digits
screencast of LeetCode Weekly Contest 128
screencast-of-leetcode-weekly-contest-12-i87g
https://www.youtube.com/watch?v=yXKBREQbBOg\n\nenjoy :)
cuiaoxiang
NORMAL
2019-03-17T10:12:08.334342+00:00
2019-03-17T10:12:08.334389+00:00
2,361
false
https://www.youtube.com/watch?v=yXKBREQbBOg\n\nenjoy :)
33
2
[]
3
numbers-with-repeated-digits
C++ Digit Dp solution
c-digit-dp-solution-by-_awm-u5ko
"""\n\n //dp[pos][tight][start][rep][mask];\n int dp[10][2][2][2][1<<10];\n vectornum;\n int solve(int pos,int tight,int start,int rep,int mask)\n
_AWM_
NORMAL
2020-03-15T07:51:13.640863+00:00
2020-03-15T07:51:13.640919+00:00
3,150
false
"""\n\n //dp[pos][tight][start][rep][mask];\n int dp[10][2][2][2][1<<10];\n vector<int>num;\n int solve(int pos,int tight,int start,int rep,int mask)\n {\n if(pos == num.size())\n {\n return rep;\n }\n int &ans= dp[pos][tight][start][rep][mask];\n if(ans!=-1)...
28
4
[]
3
numbers-with-repeated-digits
[Java] Clean Solution || with detailed explanation
java-clean-solution-with-detailed-explan-pgvc
The key to solve this problem is cleverly enumerate all numbers < n without repeated digits. One of the ways is as follow: \n\nStep 1 : count numbers with lengt
xieyun95
NORMAL
2021-05-24T22:45:34.891125+00:00
2021-05-24T22:51:30.370935+00:00
2,338
false
The key to solve this problem is cleverly enumerate all numbers < n without repeated digits. One of the ways is as follow: \n\n**Step 1 : count numbers with length smaller than n:**\n```\n// return count of numbers with d digits and no repeated digits\nprivate int totalNoRepeat(int d) {\n\tint res = 9; ...
17
0
['Java']
2
numbers-with-repeated-digits
Backtracking with C++ in a few lines
backtracking-with-c-in-a-few-lines-by-ki-hegr
\nclass Solution {\npublic:\n int uniqueDigits = 0;\n int numDupDigitsAtMostN(int N) {\n backtrack(0,0, N);\n return N - uniqueDigits + 1; /
kirakira
NORMAL
2019-03-27T09:16:15.636691+00:00
2019-03-27T09:16:15.636736+00:00
1,884
false
```\nclass Solution {\npublic:\n int uniqueDigits = 0;\n int numDupDigitsAtMostN(int N) {\n backtrack(0,0, N);\n return N - uniqueDigits + 1; // +1 as 0 is counted\n }\n \n void backtrack(long cur, int bitmask, int& N){\n if(cur > N) return;\n else uniqueDigits++;\n \n ...
17
0
[]
3
numbers-with-repeated-digits
C++ digit DP, with bitMask, with comments
c-digit-dp-with-bitmask-with-comments-by-ze50
\nclass Solution {\npublic:\n\n\tint dp[11][2][2][(1 << 10)];\n\n\n\tint solve(int pos, bool bound, bool hasRepeated, int mask, string &s) {\n\n\t\tif (pos == s
uttu_dce
NORMAL
2022-06-11T18:33:30.432006+00:00
2022-06-11T18:33:30.432035+00:00
1,458
false
```\nclass Solution {\npublic:\n\n\tint dp[11][2][2][(1 << 10)];\n\n\n\tint solve(int pos, bool bound, bool hasRepeated, int mask, string &s) {\n\n\t\tif (pos == s.length()) {\n\t\t\treturn hasRepeated ? 1 : 0;\n\t\t}\n\n\t\tif (dp[pos][bound][hasRepeated][mask] != -1) return dp[pos][bound][hasRepeated][mask];\n\n\t\ti...
13
0
['Dynamic Programming', 'Bitmask']
3
numbers-with-repeated-digits
C++ with Alternative Explanation
c-with-alternative-explanation-by-gemisi-qw8j
Really enjoyed working through this problem and pushing myself to better understand permutations because of it, and figured I\'d post my explanation of this pro
gemisis
NORMAL
2019-03-17T20:18:07.458811+00:00
2019-03-17T20:18:07.458850+00:00
1,678
false
Really enjoyed working through this problem and pushing myself to better understand permutations because of it, and figured I\'d post my explanation of this problem here. The basic idea behind this problem is to instead determine how many **invalid** numbers exist from **1-N**, rather than trying to find the valid numb...
12
1
['C++']
3
numbers-with-repeated-digits
Runtime 75 ms Beats 75.00% [EXPLAINED]
runtime-75-ms-beats-7500-explained-by-r9-7w0o
Intuition\nWhen solving this problem, I want to find out how many numbers from 1 to \uD835\uDC5B have at least one repeated digit. Instead of counting these num
r9n
NORMAL
2024-09-12T22:12:56.244421+00:00
2024-09-12T22:12:56.244442+00:00
101
false
# Intuition\nWhen solving this problem, I want to find out how many numbers from 1 to \uD835\uDC5B have at least one repeated digit. Instead of counting these numbers directly (which is hard), I use a clever trick: I count how many numbers up to \uD835\uDC5B don\'t have repeated digits, and then subtract this from \uD8...
8
0
['TypeScript']
0
numbers-with-repeated-digits
✅ [c++] || Digit DP with Bismasking || recursive+memoization
c-digit-dp-with-bismasking-recursivememo-k3hd
\nclass Solution {\npublic:\n \n int dp[11][2][1024][2]; //dp[pos][strictly][s][repeated]\n //s value can go upto 1024.\n //logic:- if we set all bi
xor09
NORMAL
2021-10-15T04:31:33.061290+00:00
2021-10-15T04:44:01.124940+00:00
1,222
false
```\nclass Solution {\npublic:\n \n int dp[11][2][1024][2]; //dp[pos][strictly][s][repeated]\n //s value can go upto 1024.\n //logic:- if we set all bit from (9...0) it gives approx. 1023 \n int solve(string& str, int pos, bool strictly, int s, bool repeated){\n if(pos==str.size()){\n i...
7
0
['Dynamic Programming', 'Recursion', 'Memoization', 'C', 'Bitmask', 'C++']
2
numbers-with-repeated-digits
C++ | Digit DP | Simplest Solution | Clean Code
c-digit-dp-simplest-solution-clean-code-2o99c
Intuition & Approach\nRather than finding numbers having repetitions, we can find: Total numbers - Numbers with all digits unique.\nMaintain a bitmask to make s
rosegold
NORMAL
2023-08-20T18:23:21.024022+00:00
2023-08-20T18:25:23.642415+00:00
556
false
# Intuition & Approach\nRather than finding numbers having repetitions, we can find: `Total numbers - Numbers with all digits unique`.\nMaintain a bitmask to make sure that we don\'t re-select a digit which has already been included.\n\n# Code\n```\nclass Solution {\npublic:\n int dp[11][2][1025]; // 1025 -> (1 << 1...
6
0
['Dynamic Programming', 'C++']
2
numbers-with-repeated-digits
Java O(1) 0ms beats all
java-o1-0ms-beats-all-by-limkinghei-0fz3
This is to count the numbers with all distinct digits.\nWe can separate into two parts... say for N = 6,543,210,\n\nwe\'ll count the distinct one from 1 to 999,
limkinghei
NORMAL
2019-03-17T22:01:36.172354+00:00
2019-03-17T22:01:36.172418+00:00
1,785
false
This is to count the numbers with all distinct digits.\nWe can separate into two parts... say for N = 6,543,210,\n\nwe\'ll count the distinct one from 1 to 999,999, which would be \n\t1-9: 9\n\tplus 10-99: 9 * 9 \n\tplus 100-999: 9 * 9 * 8\n\tplus 1,000 - 9,999: 9 * 9 * 8 * 7\n\t...\n\t100,000 - 999,999: 9 * 9 * 8 * 7 ...
6
0
[]
0
numbers-with-repeated-digits
Very Obvious , Intuitive and Easy 13D - DP :)
very-obvious-intuitive-and-easy-13d-dp-b-lqmq
\n# Code\n\nclass Solution {\npublic:\n string s;\n\n\n int dp[11][2][3][3][3][3][3][3][3][3][3][3][2];\n\n int rec(int index, bool tight, int one, int
sojabhai
NORMAL
2024-07-01T20:55:16.479675+00:00
2024-07-01T20:55:16.479697+00:00
420
false
\n# Code\n```\nclass Solution {\npublic:\n string s;\n\n\n int dp[11][2][3][3][3][3][3][3][3][3][3][3][2];\n\n int rec(int index, bool tight, int one, int two, int three, int four,\n int five, int six, int seven, int eight, int nine, int zero,\n bool lead) {\n\n if (index == s.size...
5
1
['C++']
4
numbers-with-repeated-digits
C++ || Digit DP Solution ||
c-digit-dp-solution-by-viraj7403-a2v5
Intuition\n Describe your first thoughts on how to solve this problem. \n\nlets build intuition from scratch. \nI will not direct jump into solution. \n(If you
viraj7403
NORMAL
2024-04-15T11:49:52.358007+00:00
2024-04-15T11:49:52.358037+00:00
386
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\nlets build intuition from scratch. \nI will not direct jump into solution. \n**(If you don\'t have time to read whole article you can direct go to code).** \n\n\nSo , Let\'s start: \n\n```\nApproach - 1: \n```\n\nIterate from number 1 t...
5
0
['Math', 'String', 'Dynamic Programming', 'Backtracking', 'Bit Manipulation', 'Recursion', 'Memoization', 'Bitmask', 'C++']
0
numbers-with-repeated-digits
I spent 4 hours on this shit I hate my life
i-spent-4-hours-on-this-shit-i-hate-my-l-uoj2
Intuition\n Describe your first thoughts on how to solve this problem. \nIts basically just math, Im gonna die \n# Approach\n Describe your approach to solving
FrostPanda
NORMAL
2023-02-22T16:08:33.839645+00:00
2023-02-22T16:08:33.839677+00:00
756
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIts basically just math, Im gonna die \n# Approach\n<!-- Describe your approach to solving the problem. -->\nlet n be a K digit integer\nWe will count the total number of non-duplicated integers\nWe split them up in 2 cases by counting <K...
5
0
['Python3']
1
numbers-with-repeated-digits
C++ | DIGIT-DP | BIT-MASKING
c-digit-dp-bit-masking-by-chikzz-ymh4
PLEASE UPVOTE IF U FIND MY SOLUTION HELPFUL :)\n\n\nclass Solution\n{\n int dp[1<<10][10][2][2];\n int helper(string &s,int i,int mask,int lz,int bound)\n
chikzz
NORMAL
2022-06-27T15:04:18.579035+00:00
2022-06-27T15:04:18.579078+00:00
837
false
**PLEASE UPVOTE IF U FIND MY SOLUTION HELPFUL :)**\n\n```\nclass Solution\n{\n int dp[1<<10][10][2][2];\n int helper(string &s,int i,int mask,int lz,int bound)\n {\n if(i==s.length())return 1;\n \n if(dp[mask][i][lz][bound]!=-1)\n return dp[mask][i][lz][bound];\n \n ...
5
0
['Bitmask']
4
numbers-with-repeated-digits
C# Study code from ranking No. 1 in weekly contest 128
c-study-code-from-ranking-no-1-in-weekly-34k3
March 21, 2019\nIt is one of weekly contest 128 algorithms. What I like to do is to learn ranking No. 1\'s code, and then I add some comment to explain the idea
jianminchen
NORMAL
2019-03-21T18:26:25.160119+00:00
2019-10-10T04:31:02.004789+00:00
901
false
March 21, 2019\nIt is one of weekly contest 128 algorithms. What I like to do is to learn ranking No. 1\'s code, and then I add some comment to explain the idea to make it easy to follow. The player finished the algorithm using 7 minutes 5 seconds. \n\n![image](https://assets.leetcode.com/users/jianminchen/image_155320...
5
0
[]
2
numbers-with-repeated-digits
[Python3] Digit DP + BIT Mask - Simple + Detail Explanation - Easy To Understand
python3-digit-dp-bit-mask-simple-detail-nuc2r
Intuition\nFind total of numbers in range with specific condition => digit DP\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n1. In
dolong2110
NORMAL
2024-01-13T14:35:51.968473+00:00
2024-01-13T14:35:51.968557+00:00
405
false
# Intuition\nFind total of numbers in range with specific condition => digit DP\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n1. Initialization\n- The input number `n` is converted to a list of digits (`digits`).\n2. Dynamic Programming Function\n- The function `dp` is a recursive ...
4
0
['Dynamic Programming', 'Bitmask', 'Python3']
0
numbers-with-repeated-digits
[C++] Let Backtracking do it's work , clean and crisp code
c-let-backtracking-do-its-work-clean-and-0z1y
\nclass Solution {\npublic:\n int dfs(long curr, int mask, int n) {\n if(curr > n) return 0;\n int ans=1; //since n < 123456789 and all its per
P3rf3ct0
NORMAL
2022-08-15T11:00:56.633229+00:00
2022-08-15T11:03:36.433876+00:00
450
false
```\nclass Solution {\npublic:\n int dfs(long curr, int mask, int n) {\n if(curr > n) return 0;\n int ans=1; //since n < 123456789 and all its permutations therefore 1 number always exists\n for(int i=0; i<10; i++) {\n if(!mask and !i) continue; //leading 0 not allowed\n if...
4
0
['Backtracking', 'Depth-First Search', 'C', 'Bitmask', 'C++']
0
numbers-with-repeated-digits
Digit DP
digit-dp-by-ayushman_123-v0ku
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
Ayushman_123
NORMAL
2022-07-02T08:15:55.697843+00:00
2024-06-23T12:47:58.827279+00:00
1,012
false
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...
4
0
['Python']
0
numbers-with-repeated-digits
C++ digit dp with backtracking
c-digit-dp-with-backtracking-by-sai_pras-5qst
\nclass Solution {\npublic:\n \n int anotherdp[15][2];\n \n int total(string x,int n,bool tight,set<int> &s){\n if(n==0){\n return
sai_prasad_07
NORMAL
2021-01-21T06:58:00.571786+00:00
2021-01-21T06:58:00.571819+00:00
643
false
```\nclass Solution {\npublic:\n \n int anotherdp[15][2];\n \n int total(string x,int n,bool tight,set<int> &s){\n if(n==0){\n return 1;\n }\n if(anotherdp[n][tight]!=-1){\n return anotherdp[n][tight];\n }\n int ub = (tight==1) ? x[x.length()-n]-\'0\'...
4
0
[]
0
numbers-with-repeated-digits
C++ Solution || Digit DP || Clean and Concise || Bitmask
c-solution-digit-dp-clean-and-concise-bi-6jbh
Code\n\nclass Solution {\npublic:\n\n int dp[10][2][1025][2]; //2^10 = 1024 for bitmask\n\n int count(int idx,bool tight,int bitmask,bool isrepeated,strin
Harsh_0903
NORMAL
2023-06-05T09:28:59.456414+00:00
2023-06-05T09:28:59.456455+00:00
637
false
# Code\n```\nclass Solution {\npublic:\n\n int dp[10][2][1025][2]; //2^10 = 1024 for bitmask\n\n int count(int idx,bool tight,int bitmask,bool isrepeated,string& num){\n if(idx==num.size()){\n return (isrepeated&&bitmask)?1:0;\n }\n if(dp[idx][tight][bitmask][isrepeated]!=-1) retur...
3
1
['Dynamic Programming', 'Recursion', 'Memoization', 'Bitmask', 'C++']
0
numbers-with-repeated-digits
[C++] Permutation with explaination
c-permutation-with-explaination-by-kamin-l34e
\nclass Solution {\npublic:\n int permutation(int m, int n) {\n // m number with len n\n // m * (m - 1) * (m - 2) .. * (m - n + 1) \n in
kaminyou
NORMAL
2022-05-06T15:58:34.101755+00:00
2022-05-06T15:58:34.101810+00:00
565
false
```\nclass Solution {\npublic:\n int permutation(int m, int n) {\n // m number with len n\n // m * (m - 1) * (m - 2) .. * (m - n + 1) \n int res = 1;\n while (n) {\n res *= m;\n m--;\n n--;\n }\n return res;\n }\n int numDupDigitsAtMost...
3
0
['C']
1
numbers-with-repeated-digits
[Python] Well commented solution with easy to follow recursion
python-well-commented-solution-with-easy-qzif
\nclass Solution(object):\n def numDupDigitsAtMostN(self, N):\n """\n :type N: int\n :rtype: int\n """\n memo = {}\n
algomelon
NORMAL
2020-04-23T03:09:09.882541+00:00
2020-04-23T03:13:35.345699+00:00
842
false
```\nclass Solution(object):\n def numDupDigitsAtMostN(self, N):\n """\n :type N: int\n :rtype: int\n """\n memo = {}\n def f(digits_of_N, i, digits_used, any_digit):\n if i == k:\n return 1\n \n key = (i, digits_used, any_digi...
3
0
[]
0
numbers-with-repeated-digits
Python Digit DP (Pattern For Similar Questions)
python-digit-dp-pattern-for-similar-ques-uua7
Theory: https://codeforces.com/blog/entry/53960\n\nMore of the same approach:\n902. Numbers At Most N Given Digit Set\n788. Rotated Digits\n1397. Find All Good
migfulcrum
NORMAL
2020-04-02T11:12:50.697802+00:00
2020-04-17T21:36:27.947204+00:00
1,957
false
Theory: https://codeforces.com/blog/entry/53960\n\nMore of the same approach:\n[902. Numbers At Most N Given Digit Set](https://leetcode.com/problems/numbers-at-most-n-given-digit-set/discuss/559624/python-digit-dp)\n[788. Rotated Digits](https://leetcode.com/problems/rotated-digits/discuss/560601/python-digit-dp)\n[13...
3
0
[]
0
numbers-with-repeated-digits
Correct Solution but Exceeded Time Limit
correct-solution-but-exceeded-time-limit-tjrp
This solution will give correct answer but will exceed time limit:\n```\nclass Solution:\n def numDupDigitsAtMostN(self, N: int) -> int:\n countRepeat
andrewlang
NORMAL
2019-12-24T01:34:36.254772+00:00
2019-12-24T01:34:36.254824+00:00
744
false
This solution will give correct answer but will exceed time limit:\n```\nclass Solution:\n def numDupDigitsAtMostN(self, N: int) -> int:\n countRepeat = 0\n for x in range(1, N+1):\n intList = [char for char in str(x)]\n if len(str(x)) != len(list(set(intList))):\n ...
3
0
['Python', 'Python3']
1
numbers-with-repeated-digits
Solution in Python 3 (beats ~99%)
solution-in-python-3-beats-99-by-junaidm-x7ef
```\nclass Solution:\n def numDupDigitsAtMostN(self, N: int) -> int:\n \tT = [9,261,4725,67509,831429,9287109,97654149,994388229]\n \tt = [99,999,9999,
junaidmansuri
NORMAL
2019-07-11T10:26:09.874910+00:00
2019-07-11T10:36:10.138106+00:00
1,588
false
```\nclass Solution:\n def numDupDigitsAtMostN(self, N: int) -> int:\n \tT = [9,261,4725,67509,831429,9287109,97654149,994388229]\n \tt = [99,999,9999,99999,999999,9999999,99999999,999999999]\n \tif N < 10:\n \t\treturn 0\n \tL = len(str(N))\n \tm, n = [1], []\n \tg = 11-L\n \tfor i in range(...
3
1
['Python', 'Python3']
1
numbers-with-repeated-digits
C++/Python, digit dp solution with explanation
cpython-digit-dp-solution-with-explanati-ahfo
find how many number without repeated digits\nfill a number digit by digit.\ni means we are filling i-th digit.\nmask is number we used in the number, it is a b
shun6096tw
NORMAL
2023-08-21T10:19:50.047881+00:00
2023-08-21T10:19:50.047900+00:00
135
false
### find how many number without repeated digits\nfill a number digit by digit.\ni means we are filling i-th digit.\nmask is number we used in the number, it is a bitmask, means which number we have used in [0,9].\nis_limit means the current number is on the upper bound, e.g., n = 234, and digit is 23, we are filling l...
2
0
['Dynamic Programming', 'C', 'Python']
0
numbers-with-repeated-digits
Easy Bitmask DP Solution
easy-bitmask-dp-solution-by-abhi-1301-b2nh
\n\n# Code\n\nint dp[10][1<<10][2][10];//index digit_set flag length\n\nstring s;\n\nint solve(int ind,int mask,bool f,int len)\n{\n if(ind>=len)\n re
Abhi-1301
NORMAL
2023-02-17T10:01:37.172272+00:00
2023-02-17T10:08:16.134538+00:00
1,495
false
\n\n# Code\n```\nint dp[10][1<<10][2][10];//index digit_set flag length\n\nstring s;\n\nint solve(int ind,int mask,bool f,int len)\n{\n if(ind>=len)\n return 1;\n \n auto &p=dp[ind][mask][f][len];\n\n if(p!=-1)\n return p;\n \n p=0;\n\n int maxi=9;\n\n if(f&&len==s.size())\n ...
2
0
['Dynamic Programming', 'Recursion', 'Bitmask', 'C++']
0
numbers-with-repeated-digits
0ms C++ SOLUTION
0ms-c-solution-by-obose-1kfd
Intuition\n Describe your first thoughts on how to solve this problem. \nThe idea of this solution is to count the number of integers with unique digits from 0
Obose
NORMAL
2023-01-18T03:47:55.106084+00:00
2023-01-18T03:47:55.106120+00:00
1,113
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe idea of this solution is to count the number of integers with unique digits from 0 to N, which can be done by considering the different cases for each digit. \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe ...
2
0
['C++']
1
numbers-with-repeated-digits
C++ | Standard Digit DP
c-standard-digit-dp-by-baihuaxie-48hz
This is a standard digit DP problem.\n\nA few words on digit DP for those who are not so familiar with the concept. The basic idea here is to group the sequence
baihuaxie
NORMAL
2022-08-31T01:48:25.478167+00:00
2022-08-31T01:59:43.848292+00:00
113
false
This is a standard digit DP problem.\n\nA few words on digit DP for those who are not so familiar with the concept. The basic idea here is to group the sequences into subsets or sub-problems, then apply regular top-down DP on each sub-problem. Here by "sequences" I just mean any integer within the range `[1,n]` , so th...
2
0
[]
0
numbers-with-repeated-digits
[C++] || Digit DP || Total - NonRepeating
c-digit-dp-total-nonrepeating-by-rahul92-yknl
bound variable ensures that we dont overshoot the given n value at any time.\n\n mask check which digits are taken and which are yet to be taken.\n\n pos tracks
rahul921
NORMAL
2022-08-26T01:41:51.310315+00:00
2022-08-26T01:48:14.490520+00:00
340
false
* `bound` variable ensures that we dont overshoot the given `n` value at any time.\n\n* `mask` check which digits are taken and which are yet to be taken.\n\n* `pos` tracks the length of orignal number.\n\n```\nclass Solution {\npublic:\n int dp[11][1025][2] ;\n string ref ;\n int solve(int pos, int mask , int...
2
0
['C']
1
numbers-with-repeated-digits
C++ | digit dp
c-digit-dp-by-deepanshu_johar-j3ik
\nclass Solution {\npublic:\n string num;\n int len;\n int setKthBit(int n, int k)\n {\n return ((1 << (k)) | n);\n }\n bool isKthBitSe
deepanshu_johar
NORMAL
2021-12-15T20:06:28.544780+00:00
2021-12-15T20:06:28.544808+00:00
418
false
```\nclass Solution {\npublic:\n string num;\n int len;\n int setKthBit(int n, int k)\n {\n return ((1 << (k)) | n);\n }\n bool isKthBitSet(int n, int k)\n {\n return ( n & (1 << k) );\n }\n\n // mask reprsents the set of numbers already in the number //\n // like for 1,2,4 ...
2
0
['Dynamic Programming']
0
numbers-with-repeated-digits
python easy follow
python-easy-follow-by-xjsun-430k
the basic idea here is computing the non-repeat numbers first and then use N minus the non-repeat numbers.\nsuppose N is abcde, compute non- repeat numbers smal
xjsun
NORMAL
2021-01-15T19:49:22.838227+00:00
2021-01-15T19:49:22.838279+00:00
489
false
the basic idea here is computing the non-repeat numbers first and then use N minus the non-repeat numbers.\nsuppose N is abcde, compute non- repeat numbers smaller than a0000. then compute non-repeat number between a0000 and ab000, and so on.\n\n\'\'\'\n\n\tdef numDupDigitsAtMostN(self, N: int) -> int:\n def hel...
2
0
[]
0
numbers-with-repeated-digits
Python. Easy.
python-easy-by-nag007-hlib
\ndef f(n,s,e,ci,di,v):\n if n==ci:\n return 1\n a=0\n if (e,ci,v) in di:\n return di[e,ci,v]\n for i in range(10):\n if e=
nag007
NORMAL
2020-07-10T15:59:59.376953+00:00
2020-07-10T15:59:59.376988+00:00
694
false
```\ndef f(n,s,e,ci,di,v):\n if n==ci:\n return 1\n a=0\n if (e,ci,v) in di:\n return di[e,ci,v]\n for i in range(10):\n if e==0:\n if not v>>i&1:\n eee=v|(1<<i)\n a+=f(n,s,0,ci+1,di,eee)\n else:\n if i>i...
2
4
[]
0
numbers-with-repeated-digits
Simple & Efficient C++ Digit DP solution with comments
simple-efficient-c-digit-dp-solution-wit-9gpg
Top Down multi-dimensional DP approach\n\n\n#define ll long long\n\nclass Solution {\npublic:\n string s;\n int dp[10][2][2][2][1<<10];\n\n ll ff(int p
abhisharma404
NORMAL
2020-01-23T19:37:41.065685+00:00
2020-01-23T19:38:07.025602+00:00
667
false
**Top Down multi-dimensional DP approach**\n\n```\n#define ll long long\n\nclass Solution {\npublic:\n string s;\n int dp[10][2][2][2][1<<10];\n\n ll ff(int pos, bool tight, bool st, bool cnt, int mask) {\n // If index reaches the length of the string return whether\n // any repetition till now h...
2
1
[]
6
numbers-with-repeated-digits
[C++] Share my DP solution (count the numbers without repeated digits)
c-share-my-dp-solution-count-the-numbers-9zhx
\n// DP State is current digit index, visited bitmask,\n// comparison of current number to N, left digits.\nint dp[11][2048][3][11];\n\nint sgn(int val) {\n
todor91
NORMAL
2019-04-25T06:59:51.677143+00:00
2019-04-25T06:59:51.677189+00:00
846
false
```\n// DP State is current digit index, visited bitmask,\n// comparison of current number to N, left digits.\nint dp[11][2048][3][11];\n\nint sgn(int val) {\n return (0 < val) - (val < 0);\n}\n\nclass Solution {\npublic:\n\n vector<int> N;\n \n int genAll(int curDigitIndex, int vis, int cmpN, int len) {\n ...
2
0
[]
1
numbers-with-repeated-digits
Java 0ms solution with explanations
java-0ms-solution-with-explanations-by-k-39ld
The idea is simple. Count all numbers that do not have repeating digits and less than or equal to N. Substract the count from N and return. My initial idea was
karayv
NORMAL
2019-03-18T00:06:09.687562+00:00
2019-03-18T00:06:09.687603+00:00
1,012
false
The idea is simple. Count all numbers that do not have repeating digits and less than or equal to `N`. Substract the count from `N` and return. My initial idea was to permutate 10 digits in [1..`digsCount`] slots (`digsCount` is a number of digits in `N`) and take into account those results of permutation that are <= ...
2
0
[]
1
numbers-with-repeated-digits
Math,O(logN)
mathologn-by-maxatom-jy3b
Count the number without repeated digit.\nwe start with the highest bit of N, if N is 1000, the highest bit must less than 1, so we start with 0,\nthe biggest
maxatom
NORMAL
2019-03-17T10:43:25.196324+00:00
2019-03-17T10:43:25.196391+00:00
644
false
Count the number without repeated digit.\nwe start with the highest bit of N, if N is 1000, the highest bit must less than 1, so we start with 0,\nthe biggest number without repeated dight is 999, the leghth is 3.\nthe highest bit can be 1~9 ( we count numbers start with 0 later) , the second bit can be 0~9, excludin...
2
1
[]
0
numbers-with-repeated-digits
Beats 100% | detailed solution | Python3
beats-100-detailed-solution-python3-by-a-rkob
Please UpvoteCode
Alpha2404
NORMAL
2025-04-03T17:31:44.398135+00:00
2025-04-03T17:31:44.398135+00:00
40
false
# Please Upvote # Code ```python3 [] class Solution: def numDupDigitsAtMostN(self, N: int) -> int: def permutation(m, k): # Computes the number of ways to arrange k numbers out of m possibilities. result = 1 for i in range(k): result *= (m - i) ...
1
0
['Math', 'Python3']
0
numbers-with-repeated-digits
One of the Best Digit DP + Bitmask question solution(c++ solution)
one-of-the-best-digit-dp-bitmask-questio-5e2i
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
jishudip389
NORMAL
2023-09-06T11:51:38.908634+00:00
2023-09-06T11:51:38.908656+00:00
121
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
1
0
['C++']
0
numbers-with-repeated-digits
Java easy to understand(Digit Dp + Bit Manipulation)
java-easy-to-understanddigit-dp-bit-mani-j73l
\nclass Solution {\n Integer[][][][] dp;\n private int solve(char[] num, int curDig, boolean isStrict, int bit, boolean repeated) {\n if(curDig ==
manmohansaraswat15
NORMAL
2023-06-06T05:18:35.843623+00:00
2023-06-06T05:18:35.843659+00:00
529
false
```\nclass Solution {\n Integer[][][][] dp;\n private int solve(char[] num, int curDig, boolean isStrict, int bit, boolean repeated) {\n if(curDig == num.length) return repeated ? 1 : 0;\n if(dp[curDig][isStrict ? 1 : 0][bit][repeated ? 1 : 0] != null) return dp[curDig][isStrict ? 1 : 0][bit][repeat...
1
0
['Dynamic Programming', 'Bit Manipulation', 'Recursion', 'Bitmask', 'Java']
0
numbers-with-repeated-digits
100% Faster Solution using Math and Recursion TC : O(1) || C++ Explained
100-faster-solution-using-math-and-recur-tkax
Please upvote if you like my solution .\n\nclass Solution {\npublic:\n // to return factorial starting at st and multiplying till t no of times\n int fac(
rkkumar421
NORMAL
2022-10-30T16:59:02.160104+00:00
2022-10-30T17:00:36.312812+00:00
135
false
**Please upvote if you like my solution .**\n```\nclass Solution {\npublic:\n // to return factorial starting at st and multiplying till t no of times\n int fac(int st,int t){\n int ans = 1;\n while(t){\n ans *= st;\n st--;\n t--;\n }\n return ans;\n ...
1
0
['Math', 'Recursion', 'C']
0
numbers-with-repeated-digits
C++ Solution || Digit DP Solution
c-solution-digit-dp-solution-by-shubham_-dezm
cpp\nclass Solution {\npublic:\n int dp[10][1<<10][2][2];\n int solve(string &nums,int i=0,int mask=0,bool rep=0,int tight=1){\n if(i>=nums.size())
shubham_lohan
NORMAL
2022-08-19T12:53:09.877537+00:00
2022-08-19T12:53:09.877569+00:00
108
false
```cpp\nclass Solution {\npublic:\n int dp[10][1<<10][2][2];\n int solve(string &nums,int i=0,int mask=0,bool rep=0,int tight=1){\n if(i>=nums.size())\n return rep and mask!=0;\n if(dp[i][mask][rep][tight]!=-1)\n return dp[i][mask][rep][tight];\n int ub=tight?(nums[i]-\'...
1
0
[]
1
numbers-with-repeated-digits
C++ | Greedy
c-greedy-by-tangerrine2112-f3gi
\nclass Solution {\npublic:\n int numDupDigitsAtMostN(int n) {\n vector<int> V;\n int n2 = n;\n while(n2){\n V.emplace_back(n
tangerrine2112
NORMAL
2022-08-14T05:38:51.102389+00:00
2022-08-14T05:38:51.102442+00:00
402
false
```\nclass Solution {\npublic:\n int numDupDigitsAtMostN(int n) {\n vector<int> V;\n int n2 = n;\n while(n2){\n V.emplace_back(n2%10);\n n2/=10;\n }\n int len = V.size();\n \n int sum = 0;\n for(int i = 0; i < len-1; i++){\n sum...
1
0
[]
0
numbers-with-repeated-digits
Am I the only one who misunderstand the question?
am-i-the-only-one-who-misunderstand-the-z5g61
I spent over 1 hr debugging couldn\'t figure out why my answer is wrong for some large numbers. \n\nThe question states that have at least one repeated digit. I
Student2091
NORMAL
2022-07-21T02:16:44.730412+00:00
2022-07-21T02:19:15.406031+00:00
561
false
I spent over 1 hr debugging couldn\'t figure out why my answer is wrong for some large numbers. \n\nThe question states that have at least one repeated digit. I took that to mean "101" is NOT OK because both "1" are not glued together, and "11" is OK because they are together.\n\nI eventually gave up and checked the so...
1
0
['Java']
0
numbers-with-repeated-digits
[Python] Permutation rule + Find the numbers without repeted digits
python-permutation-rule-find-the-numbers-973p
\n\nclass Solution:\n def numDupDigitsAtMostN(self, n: int) -> int:\n \n nums = [int(i) for i in str(n+1)] # digits in n+1\n d = len(num
haydarevren
NORMAL
2022-07-13T15:44:43.082039+00:00
2022-07-13T15:46:21.797476+00:00
651
false
\n```\nclass Solution:\n def numDupDigitsAtMostN(self, n: int) -> int:\n \n nums = [int(i) for i in str(n+1)] # digits in n+1\n d = len(nums) # number of digits in n+1\n res = 0 # number of no duplicates\n \n # count no duplicates for numbers with <d digits\n for i in...
1
0
['Combinatorics', 'Python']
0
numbers-with-repeated-digits
[JAVA] For if else lovers
java-for-if-else-lovers-by-_rodeo-tr05
Strategy\nWe\'re taking the problem, slice it into smaller bites, solve for the smaller bites, and\nadd up what we calculate in each slice. \n\nSolution\nImagin
_rodeo_
NORMAL
2021-11-02T23:51:37.616118+00:00
2021-11-02T23:51:37.616150+00:00
721
false
**Strategy**\nWe\'re taking the problem, slice it into smaller bites, solve for the smaller bites, and\nadd up what we calculate in each slice. \n\n**Solution**\nImagine we have three digits, x, y, and z. There are multiple ways to have a permutation\nof these digits such that at least one of the digits is repeated. Le...
1
0
['Probability and Statistics', 'Java']
0
numbers-with-repeated-digits
Python O(1) time
python-o1-time-by-decomplexifier-n2j8
The idea is to first count the numbers that have distinct digits. There are two cases. (1) Without the limitation of being at most n, there are 9*9*8*...(9-k+2)
decomplexifier
NORMAL
2021-08-16T06:16:37.565979+00:00
2021-08-16T06:19:03.197777+00:00
487
false
The idea is to first count the numbers that have distinct digits. There are two cases. (1) Without the limitation of being at most `n`, there are `9*9*8*...(9-k+2)` such numbers with `k` digits. (2) With the limitation `n`, we can count such numbers in ranges. For example, for `n = 3579`, we count the numbers with dist...
1
0
[]
0
numbers-with-repeated-digits
[Java] dfs+memo+bit
java-dfsmemobit-by-66brother-seyk
\nclass Solution {\n int dp[][][];\n public int numDupDigitsAtMostN(int N) {\n //at least 1 repeat digit\n if(N<=10)return 0;\n Strin
66brother
NORMAL
2020-09-09T00:59:28.028809+00:00
2020-09-09T01:04:25.858482+00:00
371
false
```\nclass Solution {\n int dp[][][];\n public int numDupDigitsAtMostN(int N) {\n //at least 1 repeat digit\n if(N<=10)return 0;\n String s=N+"";\n int cnt=0;\n int first=s.charAt(0)-\'0\';\n dp=new int[s.length()][1<<10][2];\n \n for(int i=0;i<dp.length;i++...
1
0
[]
1
numbers-with-repeated-digits
constant time combinatorial counting
constant-time-combinatorial-counting-by-jgs3x
(A similar problem: https://leetcode.com/problems/ones-and-zeroes/)\n\nIf you studied probability, it is well known that considering the complement problem: \'t
vvave
NORMAL
2019-09-29T18:27:51.877585+00:00
2019-09-29T18:33:05.110333+00:00
246
false
(A similar problem: https://leetcode.com/problems/ones-and-zeroes/)\n\nIf you studied probability, it is well known that considering the complement problem: \'the count of number WITHOUT repeating digit that\'s less than N\' is easier to solve. And then we get the answer by subtracting this cnt from N.\n\nSo numbers M ...
1
0
[]
0
numbers-with-repeated-digits
Java Digital DP
java-digital-dp-by-pokehunter-j191
java\nclass Solution {\n public int numDupDigitsAtMostN(int N) {\n int[] digits = new int[10];\n int pos = 0, temp = N;\n while (N > 0)
pokehunter
NORMAL
2019-09-21T08:03:16.167059+00:00
2019-09-21T08:03:16.167103+00:00
631
false
```java\nclass Solution {\n public int numDupDigitsAtMostN(int N) {\n int[] digits = new int[10];\n int pos = 0, temp = N;\n while (N > 0) {\n digits[pos++] = N % 10;\n N /= 10;\n }\n return temp - dfs(digits, pos - 1, 0, new int[10][1 << 10], true) + 1;\n ...
1
0
[]
2
numbers-with-repeated-digits
C++ Divide-and-conquer
c-divide-and-conquer-by-sanzenin_aria-b5jd
I guess no one want to read this long solution. So I am lazy to add comment\n```\nclass Solution {\npublic:\n int numDupDigitsAtMostN(int N) {\n vector v
sanzenin_aria
NORMAL
2019-06-19T01:29:23.037689+00:00
2019-06-19T01:37:38.834697+00:00
412
false
I guess no one want to read this long solution. So I am lazy to add comment\n```\nclass Solution {\npublic:\n int numDupDigitsAtMostN(int N) {\n vector<int> v = toVec(N);\n int n1 = numNoRepeat1(v, {}, 0);\n int n2 = numNoRepeat2(v.size() - 1);\n cout << N << " " << n1 << " " << n2 << endl;\n ...
1
0
[]
0
numbers-with-repeated-digits
C# standard depth first search with back tracking
c-standard-depth-first-search-with-back-m5cxu
March 21, 2019\nIt is the hard level algorithm. I like to share the standard depth first search using back tracking technique to solve the problem. What I did i
jianminchen
NORMAL
2019-03-21T21:13:51.933991+00:00
2019-10-10T04:31:32.855618+00:00
433
false
March 21, 2019\nIt is the hard level algorithm. I like to share the standard depth first search using back tracking technique to solve the problem. What I did is to study weekly contest 128 ranking 13 player\'s code, and then I wrote one based on my understanding. \n\nHere are steps to follow:\n1. Brute force solution,...
1
0
[]
1
numbers-with-repeated-digits
C++ method using permutation
c-method-using-permutation-by-lingtengqi-v1tg
\nauto __ =[]()\n{\n std::ios::sync_with_stdio(false);\n cin.tie(nullptr);\n return nullptr;\n}();\nclass Solution {\npublic:\n int numDupDigitsAtMo
lingtengqiu
NORMAL
2019-03-18T06:49:11.037706+00:00
2019-03-18T06:49:11.037748+00:00
461
false
```\nauto __ =[]()\n{\n std::ios::sync_with_stdio(false);\n cin.tie(nullptr);\n return nullptr;\n}();\nclass Solution {\npublic:\n int numDupDigitsAtMostN(int N) {\n //\u65E2\u7136\u8BA1\u7B97\u7684\u662F\u91CD\u590D\u7684\u4E2A\u6570\u6211\u4EEC\u53EF\u4EE5\u8BA1\u7B97\u4E0D\u91CD\u590D\u7684\u4E2A\...
1
0
[]
0
numbers-with-repeated-digits
golang dp
golang-dp-by-lddlinan-0x9x
\ncount(0, dn...d1) = count(0, 9...9) + count(10...0, dn...d1)\ncount(10...0, dn...d1) = count(10...0, dn0...0-1) + count(dn0...0, dn...d1)\n\ndefine dp(s, n),
lddlinan
NORMAL
2019-03-17T06:41:05.449380+00:00
2019-03-17T06:41:05.449410+00:00
256
false
\ncount(0, dn...d1) = count(0, 9...9) + count(10...0, dn...d1)\ncount(10...0, dn...d1) = count(10...0, dn0...0-1) + count(dn0...0, dn...d1)\n\ndefine dp(s, n), the count for numbers who has n-digits not determined yet and s is its 0-9 indicator for its known digits. (do not care whether its known digits are all 0s)\ndp...
1
0
[]
0
numbers-with-repeated-digits
Digit Dp Soln
digit-dp-soln-by-ptfan-d64o
class Solution {\npublic:\n string num;\n int l ;\n int dp[11][2][2][1030];\n \n int d(int N)\n {\n int c = 0;\n while(N)\n
ptfan
NORMAL
2019-03-17T06:17:32.181529+00:00
2019-03-17T06:17:32.181598+00:00
794
false
class Solution {\npublic:\n string num;\n int l ;\n int dp[11][2][2][1030];\n \n int d(int N)\n {\n int c = 0;\n while(N)\n {\n c++;\n N /= 10;\n }\n return c;\n }\n \n int solve(int bit, int tight, int nonz, int mask)\n {\n i...
1
0
[]
1
numbers-with-repeated-digits
Simple || Digit DP || Bitmasking
simple-digit-dp-bitmasking-by-_phoenix_1-mb2d
IntuitionApproachComplexity Time complexity: O(k∗2∗1024∗2) where k represent the number of Digit in n Space complexity: O(k∗2∗1024∗2) where k represent t
_Phoenix_14
NORMAL
2025-04-10T10:54:39.989917+00:00
2025-04-10T10:54:39.989917+00:00
10
false
# Intuition Modified the standard Digit DP approach # Approach Started masking digits after occurance of a non zero digit i.e. skipping leading zeros as they can repeat multiple times # Complexity - Time complexity: O(k∗2∗1024∗2) where k represent the number of Digit in n - Space complexity: O(k∗2∗102...
0
0
['Math', 'Dynamic Programming', 'C++']
0
numbers-with-repeated-digits
Numbers With Repeated Digits
numbers-with-repeated-digits-by-ujju27-1owc
IntuitionInstead of counting numbers with repeated digits directly, we use a complement approach: Count numbers that only have unique digits (easier to compute)
UjjU27
NORMAL
2025-03-03T21:10:42.548260+00:00
2025-03-03T21:10:42.548260+00:00
16
false
# Intuition Instead of counting numbers with repeated digits directly, we use a complement approach: Count numbers that only have unique digits (easier to compute). Subtract from n to get the count of numbers with at least one repeated digit. Example For n = 100, we count: Unique digit numbers (1-100): {1, 2, 3, ..., ...
0
0
['Java']
0
numbers-with-repeated-digits
🧮 Digit DP with Bitmask 🔢 | Time: O(10 × 2^10 × log n) | Space: O(10 × 2^10)
digit-dp-with-bitmask-time-o10-x-210-x-l-hv0e
IntuitionThis problem asks to find the number of positive integers less than or equal to n that have at least one repeated digit. A direct approach would be ine
holdmypotion
NORMAL
2025-02-26T19:09:39.928306+00:00
2025-02-26T19:09:39.928306+00:00
6
false
# Intuition This problem asks to find the number of positive integers less than or equal to `n` that have at least one repeated digit. A direct approach would be inefficient, requiring checking each number from 1 to n. Instead, the solution uses a complementary counting technique: find all numbers with no repeated dig...
0
0
['Dynamic Programming', 'Python3']
0
numbers-with-repeated-digits
easy solution but throwing tle (
easy-solution-but-throwing-tle-by-lovell-5xlp
Code
lovell3232
NORMAL
2025-01-30T11:17:53.177427+00:00
2025-01-30T11:17:53.177427+00:00
7
false
# Code ```python3 [] class Solution: def numDupDigitsAtMostN(self, n: int) -> int: c = 0 for y in range(0, n+1): if len(set(str(y))) != len(str(y)): c += 1 return c ```
0
0
['Python3']
0
numbers-with-repeated-digits
Python Hard Digit DP + Bitmask
python-hard-digit-dp-bitmask-by-lucassch-kwj1
null
lucasschnee
NORMAL
2025-01-07T16:18:40.432693+00:00
2025-01-07T16:18:40.432693+00:00
8
false
```python3 [] class Solution: def numDupDigitsAtMostN(self, n: int) -> int: ''' all - none digit dp free and constrained ''' s = str(n) N = len(s) @cache def free(index, used): if index == N: return 1 t = 0 ...
0
0
['Python3']
0
numbers-with-repeated-digits
1012. Numbers With Repeated Digits
1012-numbers-with-repeated-digits-by-g8x-636c
IntuitionApproachComplexity Time complexity: Space complexity: Code
G8xd0QPqTy
NORMAL
2025-01-01T12:50:08.734222+00:00
2025-01-01T12:50:08.734222+00:00
8
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
0
0
['C++']
0
numbers-with-repeated-digits
O(1) / O(1) via precomputation
o1-o1-via-precomputation-by-adam-hoelsch-q975
IntuitionThere are far more numbers that have repeated digits than those that don't. If we can efficiently enumerate all the numbers that do not have repeated d
adam-hoelscher
NORMAL
2024-12-25T08:34:29.731091+00:00
2025-01-06T17:51:51.174837+00:00
10
false
# Intuition There are far more numbers that have repeated digits than those that don't. If we can efficiently enumerate all the numbers that do not have repeated digits into a sorted array, then we can use a binary search to efficiently count the number that are less than `n+1`. Subtracting that from `n` will give us t...
0
0
['Go']
0
numbers-with-repeated-digits
Track repeat using bit mask then digit dp
track-repeat-using-bit-mask-then-digit-d-g4tw
Intuition\n Describe your first thoughts on how to solve this problem. \nWe can keep a track of digits used so far using a bit mask and if digit we are trying t
el-profesor
NORMAL
2024-11-03T12:37:39.947681+00:00
2024-11-03T12:37:39.947705+00:00
7
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe can keep a track of digits used so far using a bit mask and if digit we are trying to use now is already set in the bit mask then set the \'repeat\' variable to 1 (or true)\n\n\n# Approach\n<!-- Describe your approach to solving the pr...
0
0
['Python3']
0
numbers-with-repeated-digits
Solution using Digit DP by Top-down and Bottom-up
solution-using-digit-dp-by-top-down-and-mn4fb
Code\n\n### Top-down approach\npython3 []\nclass Solution:\n def convert(self, digit):\n return ord(digit) - ord(\'0\')\n\n # f1 bool: has smaller
trieutrng
NORMAL
2024-10-05T08:40:27.549965+00:00
2024-10-05T08:40:27.549986+00:00
15
false
# Code\n\n### Top-down approach\n```python3 []\nclass Solution:\n def convert(self, digit):\n return ord(digit) - ord(\'0\')\n\n # f1 bool: has smaller digit appeared?\n # f2 int: bitmask for tracking appeared digits\n # f3 bool: leading zeros?\n def digitDP(self, i, f1, f2, f3, s, dp):\n i...
0
0
['Dynamic Programming', 'Bitmask', 'Python3']
0
numbers-with-repeated-digits
4 dimensions Digit DP - Top-Down approach
4-dimensions-digit-dp-top-down-approach-c94qc
Code\npython3 []\nclass Solution:\n def convert(self, digit):\n return ord(digit) - ord(\'0\')\n\n # f1 bool: has smaller digit appeared?\n # f2
trieutrng
NORMAL
2024-10-05T03:43:55.099296+00:00
2024-10-05T08:00:35.675299+00:00
13
false
# Code\n```python3 []\nclass Solution:\n def convert(self, digit):\n return ord(digit) - ord(\'0\')\n\n # f1 bool: has smaller digit appeared?\n # f2 int: bitmask for tracking appeared digits\n # f3 bool: leading zeros?\n def digitDP(self, i, f1, f2, f3, s, dp):\n if i>=len(s):\n ...
0
0
['Dynamic Programming', 'Bitmask', 'Python3']
0
numbers-with-repeated-digits
Bitmask DP + Digit DP | C++ 17ms Solution
bitmask-dp-digit-dp-c-17ms-solution-by-n-fw8k
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
noobita_07
NORMAL
2024-09-30T12:03:02.631882+00:00
2024-09-30T12:03:02.631917+00:00
8
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Dynamic Programming', 'C++']
0
numbers-with-repeated-digits
[c++] dp bitmask
c-dp-bitmask-by-vl4deee11-a9o5
\n#include <iostream>\n#include <queue>\n#include <vector>\n#include <cmath>\n#include <string>\n#include <sstream>\n#include <cstring>\n#include <algorithm>\n#
vl4deee11
NORMAL
2024-09-27T14:33:55.334113+00:00
2024-09-27T14:33:55.334150+00:00
0
false
```\n#include <iostream>\n#include <queue>\n#include <vector>\n#include <cmath>\n#include <string>\n#include <sstream>\n#include <cstring>\n#include <algorithm>\n#include <climits>\n#include <stack>\n#include <set>\n#include <map>\n#include <list>\n#include <cassert>\n#include <unordered_map>\n#include <numeric>\n#incl...
0
0
[]
0
numbers-with-repeated-digits
Digit DP with Bitmasking
digit-dp-with-bitmasking-by-anshab45-kfqy
Intuition\nThe goal is to count how many numbers up to a given number n have repeated digits. To solve this, we use digit DP. \n\nThe idea is to break down the
ANSHAB45
NORMAL
2024-09-12T09:00:10.731675+00:00
2024-09-12T09:00:10.731740+00:00
11
false
# Intuition\nThe goal is to count how many numbers up to a given number `n` have repeated digits. To solve this, we use **digit DP**. \n\nThe idea is to break down the problem digit by digit and track the state of the number being formed.\n\nWe use a bitmask to keep track of which digits have been used so far.\n\n# App...
0
0
['Recursion', 'Memoization', 'C++']
0
numbers-with-repeated-digits
Numbers With Repeated Digits || DP || C++
numbers-with-repeated-digits-dp-c-by-dna-ypgb
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
dnanper
NORMAL
2024-09-09T09:42:53.477058+00:00
2024-09-09T09:42:53.477087+00:00
8
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['C++']
0
numbers-with-repeated-digits
1012. Numbers With Repeated Digits.cpp
1012-numbers-with-repeated-digitscpp-by-teqmm
Code\n\nclass Solution {\npublic:\n int numDupDigitsAtMostN(int n) {\n vector<int> V;\n int n2 = n;\n while(n2){\n V.emplace_
202021ganesh
NORMAL
2024-08-31T10:18:38.056627+00:00
2024-08-31T10:18:38.056645+00:00
1
false
**Code**\n```\nclass Solution {\npublic:\n int numDupDigitsAtMostN(int n) {\n vector<int> V;\n int n2 = n;\n while(n2){\n V.emplace_back(n2%10);\n n2/=10;\n }\n int len = V.size(); \n int sum = 0;\n for(int i = 0; i < len-1; i++){\n ...
0
0
['C']
0
numbers-with-repeated-digits
Numbers With Repeated Digits
numbers-with-repeated-digits-by-shaludro-g6hg
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
Shaludroid
NORMAL
2024-08-19T19:35:01.373993+00:00
2024-08-19T19:35:01.374026+00:00
21
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Java']
0
numbers-with-repeated-digits
Beats 100% (0ms) | Java | Combinatorial solution and explanation without digit dp/recursion
beats-100-0ms-java-combinatorial-solutio-cph4
Intuition\nRather than computing how many numbers in a range have a repeated digit, it may be easired to compute how many numbers have no repeated digits and t
TheBFL
NORMAL
2024-07-23T05:12:59.148499+00:00
2024-07-23T15:23:54.215564+00:00
108
false
# Intuition\nRather than computing how many numbers in a range have a repeated digit, it may be easired to compute how many numbers have no repeated digits and then subtract that from the total number of numbers in the range. \nThe problem then is reduced to finding a fast way to enumerate non-repeating numbers in a r...
0
0
['Math', 'Combinatorics', 'Java']
0
numbers-with-repeated-digits
100 % runtime 0ms Easy and intuitive
100-runtime-0ms-easy-and-intuitive-by-aa-gg0i
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nSimply find the count o
Aaditya_26
NORMAL
2024-07-21T18:12:06.933422+00:00
2024-07-21T18:12:06.933450+00:00
11
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nSimply find the count of all number that have all digits unique and then eventually subtract from given n . \n\n\n\n\n# Complexity\n- Time complexity:\n<!-- Add your t...
0
0
['C++']
0
numbers-with-repeated-digits
Numbers With Repeated Digits
numbers-with-repeated-digits-by-sam_neam-lif3
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
Sam_Neamah
NORMAL
2024-07-03T14:07:22.455729+00:00
2024-07-03T14:07:22.455760+00:00
10
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['JavaScript']
0
numbers-with-repeated-digits
Python (Simple Digit DP)
python-simple-digit-dp-by-rnotappl-3ash
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
rnotappl
NORMAL
2024-06-20T15:46:21.466097+00:00
2024-06-20T15:46:21.466132+00:00
59
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Python3']
0
numbers-with-repeated-digits
Swift | Recursive, *non* DP solution
swift-recursive-non-dp-solution-by-pagaf-knkh
The idea is to generate all numbers <= n that have unique digits and subtract the count from n.\n\nFinding the numbers with no repeated digits is very much liki
pagafan7as
NORMAL
2024-06-14T23:45:29.152700+00:00
2024-06-14T23:45:29.152717+00:00
12
false
The idea is to generate all numbers <= n that have unique digits and subtract the count from n.\n\nFinding the numbers with no repeated digits is very much liking generating all the permutations of 0123456789, so it\'s a well known problem.\n\nBecause there are not that many such numbers (say less than a few million), ...
0
0
['Swift']
0
numbers-with-repeated-digits
94% Running Time Faster, yet simple python solution
94-running-time-faster-yet-simple-python-3cts
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
runorz
NORMAL
2024-06-01T12:43:24.269837+00:00
2024-06-01T12:43:24.269869+00:00
43
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Python3']
0
numbers-with-repeated-digits
Short and concise C++ solution | Digit DP
short-and-concise-c-solution-digit-dp-by-6ulq
Intuition\nSimple digit dp problem , check if current constructed number is less than the given number and choose digits accordingly.\nTo check if a digit is re
ratuldawar11
NORMAL
2024-05-29T03:39:31.262896+00:00
2024-05-29T03:39:31.262923+00:00
16
false
# Intuition\nSimple digit dp problem , check if current constructed number is less than the given number and choose digits accordingly.\nTo check if a digit is repeated or not use a 0-9 digit bit mask.\n\n\n# Code\n```\nclass Solution {\npublic:\n int dp[10][2][2][1<<10];\n int recur(int curr,int isLess, bool isR...
0
0
['C++']
0
numbers-with-repeated-digits
c++ sol
c-sol-by-aaditi01-3fou
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
Aaditi01
NORMAL
2024-03-29T14:13:04.027219+00:00
2024-03-29T14:13:04.027269+00:00
17
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['C++']
0
numbers-with-repeated-digits
C++ | Digit Dp | Video Solution | 77% faster than others!
c-digit-dp-video-solution-77-faster-than-984a
Digit Dp\n\n# Video Solution\n\nhttps://youtu.be/IKQSexsR7eE?si=5Mnk7J7MYc2YycON\n\n# Code\n\nclass Solution {\npublic:\n int dp[11][2][1<<10][2];\n int f
mj_08
NORMAL
2024-03-28T08:53:28.590083+00:00
2024-03-28T08:55:55.464579+00:00
5
false
# Digit Dp\n\n# Video Solution\n\n[https://youtu.be/IKQSexsR7eE?si=5Mnk7J7MYc2YycON]()\n\n# Code\n```\nclass Solution {\npublic:\n int dp[11][2][1<<10][2];\n int f(int i,string& s,int lz,int mask,int ise){\n if(i==s.size()) return 1;\n if(dp[i][lz][mask][ise]!=-1) return dp[i][lz][mask][ise];\n ...
0
0
['Math', 'Dynamic Programming', 'Brainteaser', 'Memoization', 'Bitmask', 'C++']
0
numbers-with-repeated-digits
BitMask DP || C++
bitmask-dp-c-by-bhanunegi420-qvxp
Intuition\nFinding numbers with at least one repeated digits means finding numbers with all unique digits and subtracting it from n this will give us the digits
bhanunegi420
NORMAL
2024-03-25T17:14:37.853933+00:00
2024-03-25T17:16:31.272372+00:00
18
false
# Intuition\nFinding numbers with at least one repeated digits means finding numbers with all unique digits and subtracting it from $$n$$ this will give us the digits with at least one repeated digit in it.\nNow we Divide the problem into two parts in the first part we will calculate number of unique numbers in the ran...
0
0
['Dynamic Programming', 'Bit Manipulation', 'Bitmask', 'C++']
0
numbers-with-repeated-digits
use bitmask dp
use-bitmask-dp-by-priyanshu_gupta_9620-aba8
Code\n\nclass Solution {\npublic:\n int rec(int ind,int mask,int f,int limit,vector<vector<vector<vector<int>>>>&dp,string &s){\n if(ind==s.size()){\n
Priyanshu_gupta_9620
NORMAL
2024-03-14T16:51:34.473367+00:00
2024-03-14T16:51:34.473405+00:00
5
false
# Code\n```\nclass Solution {\npublic:\n int rec(int ind,int mask,int f,int limit,vector<vector<vector<vector<int>>>>&dp,string &s){\n if(ind==s.size()){\n if(!f){\n return 0;\n }\n return 1;\n }\n else if(dp[ind][mask][f][limit]!=-1){\n ...
0
0
['C++']
0
numbers-with-repeated-digits
Digit DP and Bitmasking Solution
digit-dp-and-bitmasking-solution-by-josh-i0y9
\n\n# Code\n\nclass Solution {\npublic:\n int digits[10];\n int dp[10][2][2][2][1024];\n\n int solve(int pos, int tight, int repeated, int zero, int ma
Joshiiii
NORMAL
2024-03-12T11:59:48.735903+00:00
2024-03-12T11:59:48.735927+00:00
10
false
\n\n# Code\n```\nclass Solution {\npublic:\n int digits[10];\n int dp[10][2][2][2][1024];\n\n int solve(int pos, int tight, int repeated, int zero, int mask, string &s) {\n if (pos == s.length())\n return !zero && repeated;\n\n if (dp[pos][tight][repeated][zero][mask] != -1)\n ...
0
0
['Dynamic Programming', 'Bitmask', 'C++']
0
numbers-with-repeated-digits
Python Solution Using Combinatorics and beats 94% of submissions
python-solution-using-combinatorics-and-duki8
Code\n\nclass Solution:\n def numDupDigitsAtMostN(self, n: int) -> int:\n strn = str(n)\n length = len(strn)\n low = 0\n for i in
hassan_abioye
NORMAL
2024-02-15T02:14:14.148976+00:00
2024-02-15T02:14:14.149021+00:00
68
false
# Code\n```\nclass Solution:\n def numDupDigitsAtMostN(self, n: int) -> int:\n strn = str(n)\n length = len(strn)\n low = 0\n for i in range(1,length):\n low+=(9*(math.factorial(9)//math.factorial(9-i+1)))\n topval = int(strn[0])\n diff = topval-1\n mid=dif...
0
0
['Python3']
0
numbers-with-repeated-digits
TS Solution
ts-solution-by-gennadysx-whi5
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
GennadySX
NORMAL
2024-02-09T06:53:50.415281+00:00
2024-02-09T06:53:50.415308+00:00
3
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['TypeScript']
0
numbers-with-repeated-digits
Simple Approach using digit DP
simple-approach-using-digit-dp-by-pythag-4p6n
Code\n\nclass Solution {\npublic:\n int dp[12][1<<10][2][2];\n int func(string &num, int n, int vis, bool tight, bool zer){\n if(n==0){\n
Pythagoras235
NORMAL
2024-02-07T16:26:03.849995+00:00
2024-02-07T16:26:03.850022+00:00
16
false
# Code\n```\nclass Solution {\npublic:\n int dp[12][1<<10][2][2];\n int func(string &num, int n, int vis, bool tight, bool zer){\n if(n==0){\n return 1;\n }\n if(dp[n][vis][tight][zer]!=-1) return dp[n][vis][tight][zer];\n int ans = 0;\n int ub = tight ? (num[num.leng...
0
0
['C++']
0
numbers-with-repeated-digits
Digit DP || Short & Simple Code || Explained
digit-dp-short-simple-code-explained-by-vmmhl
Intuition\n\nNo. having at least = Total - No. having only\n 1 repeating digit Numbers unique digits\n\n=> Ans = n+1 -
coder_rastogi_21
NORMAL
2024-02-07T13:33:03.403559+00:00
2024-02-07T13:33:03.403583+00:00
34
false
# Intuition\n```\nNo. having at least = Total - No. having only\n 1 repeating digit Numbers unique digits\n\n=> Ans = n+1 - solve(.........)\n```\n# Complexity\n- Time complexity: $$O(11*2*2*1024)$$ \n\n- Space complexity: $$O(11*2*2*1024)$$ \n\n# Code\n```\n\'int dp[11][2][2][1...
0
0
['Dynamic Programming', 'C++']
0
numbers-with-repeated-digits
Solution
solution-by-penrosecat-2lzi
Intuition\n Describe your first thoughts on how to solve this problem. \n\nDigit dp. Try to find the numbers without repeated digits from 1 to N. Then subtract
penrosecat
NORMAL
2024-01-26T15:53:45.205343+00:00
2024-01-26T15:53:45.205367+00:00
14
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\nDigit dp. Try to find the numbers without repeated digits from 1 to N. Then subtract this from N.\n\n1. DP form: knapsack. We pick from what digit we want at what position. We decide the num1 and num2 between which we calculate beforeha...
0
0
['C++']
0
numbers-with-repeated-digits
very simple digit DP even beginners can understand
very-simple-digit-dp-even-beginners-can-g66vo
Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem seems to involve counting the number of unique digits in numbers up to a gi
MohdShahjahan
NORMAL
2024-01-08T10:35:26.492453+00:00
2024-01-08T10:35:26.492494+00:00
45
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem seems to involve counting the number of unique digits in numbers up to a given value n. The use of dynamic programming suggests that there might be overlapping subproblems that can be optimized.\n\n# Approach\n<!-- Describe yo...
0
0
['Dynamic Programming', 'Recursion', 'Memoization', 'C++']
0
numbers-with-repeated-digits
Java
java-by-ogyrchik14479-a5gs
\n# Code\n\nclass Solution {\n public int numDupDigitsAtMostN(int N) {\n // \u041F\u0440\u0435\u043E\u0431\u0440\u0430\u0437\u0443\u0435\u043C N + 1 \
Ogyrchik14479
NORMAL
2023-12-16T21:31:49.662344+00:00
2023-12-16T21:33:43.296941+00:00
31
false
\n# Code\n```\nclass Solution {\n public int numDupDigitsAtMostN(int N) {\n // \u041F\u0440\u0435\u043E\u0431\u0440\u0430\u0437\u0443\u0435\u043C N + 1 \u0432 \u0441\u0442\u0440\u043E\u043A\u0443, \u0442\u0430\u043A \u043A\u0430\u043A \u043D\u0430\u043C \u043D\u0443\u0436\u043D\u043E \u0432\u043A\u043B\u044E\...
0
0
['Java']
0
numbers-with-repeated-digits
Digit DP
digit-dp-by-deleted_user-qm2c
Code\n\nclass Solution {\npublic:\n int dp[10][2][1025][10];\n int solve(int index, int tight, int mask, int zeroCount, string &s) {\n if(index ==
deleted_user
NORMAL
2023-12-15T20:19:56.929188+00:00
2023-12-15T20:19:56.929228+00:00
8
false
# Code\n```\nclass Solution {\npublic:\n int dp[10][2][1025][10];\n int solve(int index, int tight, int mask, int zeroCount, string &s) {\n if(index == s.length()) {\n return 1;\n }\n if(dp[index][tight][mask][zeroCount] != -1) {\n return dp[index][tight][mask][zeroCount...
0
0
['C++']
0
numbers-with-repeated-digits
JAVA || Digit DP
java-digit-dp-by-vsai5120-9i5t
Complexity\n- Time complexity: O(num.length() * 2 * 2^10)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(num.length() * 2 * 2^10)\n Add yo
vsai5120
NORMAL
2023-11-08T19:11:59.944000+00:00
2023-11-08T19:11:59.944020+00:00
73
false
# Complexity\n- Time complexity: O(num.length() * 2 * 2^10)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(num.length() * 2 * 2^10)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int numDupDigitsAtMostN(int n) {\n String num ...
0
0
['Dynamic Programming', 'Memoization', 'Java']
0
numbers-with-repeated-digits
Digit DP C++
digit-dp-c-by-aglakshya02-jxag
Code\n\nclass Solution {\npublic:\n\n // Digit DP with bitmask\n\n string s;\n int n;\n\n int dp[10][2][1<<10][2][2];\n\n int f(int i, int tight,
aglakshya02
NORMAL
2023-10-14T06:00:42.937094+00:00
2023-10-14T06:00:42.937119+00:00
21
false
# Code\n```\nclass Solution {\npublic:\n\n // Digit DP with bitmask\n\n string s;\n int n;\n\n int dp[10][2][1<<10][2][2];\n\n int f(int i, int tight, int mask, int repeat, int allzeros){\n if(i==n)return repeat==1 && allzeros == 1;\n\n if(dp[i][tight][mask][repeat][allzeros] != -1) return ...
0
0
['C++']
0
numbers-with-repeated-digits
Digit DP + Bitmask
digit-dp-bitmask-by-nuagen-45cv
Code\n\nclass Solution {\npublic:\n\n int dp[10][2][2][2][1024];\n\n int okay(string s, int i, bool tight, bool lead, bool dup, int mask)\n {\n
Nuagen
NORMAL
2023-10-05T11:54:32.475737+00:00
2023-10-05T11:54:32.475765+00:00
22
false
# Code\n```\nclass Solution {\npublic:\n\n int dp[10][2][2][2][1024];\n\n int okay(string s, int i, bool tight, bool lead, bool dup, int mask)\n {\n if(i == s.size())\n {\n return dup;\n }\n\n if(dp[i][tight][lead][dup][mask] != -1)\n {\n return dp[i][ti...
0
0
['Math', 'Dynamic Programming', 'Bitmask', 'C++']
0
numbers-with-repeated-digits
Digit DP + Bitmask
digit-dp-bitmask-by-nuagen-fixf
Code\n\nclass Solution {\npublic:\n\n int dp[10][2][2][2][1024];\n\n int okay(string s, int i, bool tight, bool lead, bool dup, int mask)\n {\n
Nuagen
NORMAL
2023-10-05T11:53:45.243748+00:00
2023-10-05T11:53:45.243773+00:00
10
false
# Code\n```\nclass Solution {\npublic:\n\n int dp[10][2][2][2][1024];\n\n int okay(string s, int i, bool tight, bool lead, bool dup, int mask)\n {\n if(i == s.size())\n {\n return dup;\n }\n\n if(dp[i][tight][lead][dup][mask] != -1)\n {\n return dp[i][ti...
0
0
['Math', 'Dynamic Programming', 'Bitmask', 'C++']
0
numbers-with-repeated-digits
Digit DP + Bitmask
digit-dp-bitmask-by-nuagen-3zqv
Code\n\nclass Solution {\npublic:\n\n int dp[10][2][2][2][1024];\n\n int okay(string s, int i, bool tight, bool lead, bool dup, int mask)\n {\n
Nuagen
NORMAL
2023-10-05T11:53:05.586324+00:00
2023-10-05T11:53:05.586347+00:00
5
false
# Code\n```\nclass Solution {\npublic:\n\n int dp[10][2][2][2][1024];\n\n int okay(string s, int i, bool tight, bool lead, bool dup, int mask)\n {\n if(i == s.size())\n {\n return dup;\n }\n\n if(dp[i][tight][lead][dup][mask] != -1)\n {\n return dp[i][ti...
0
0
['C++']
0
number-of-subsequences-that-satisfy-the-given-sum-condition
[Java/C++/Python] Two Sum
javacpython-two-sum-by-lee215-cgha
Intuition\nAlmost same as problem two sum.\nIf we want to know the count of subarray in sorted array A,\nthen it\'s exactly the same.\nMake sure you can do two
lee215
NORMAL
2020-06-28T05:10:46.101498+00:00
2020-09-17T08:14:12.961139+00:00
51,617
false
# **Intuition**\nAlmost same as problem two sum.\nIf we want to know the count of subarray in sorted array `A`,\nthen it\'s exactly the same.\nMake sure you can do two sum before continue.\n<br>\n\n# **Explanation**\nSort input `A` first,\nFor each `A[i]`, find out the maximum `A[j]`\nthat `A[i] + A[j] <= target`.\n\nF...
564
3
[]
79