11 N Digit numbers with digits in increasing order
Вставка
- Опубліковано 9 лют 2024
- Given an integer N, print all the N digit numbers in increasing order, such that their digits are in strictly increasing order(from left to right).
Example 1:
Input:
N = 1
Output:
0 1 2 3 4 5 6 7 8 9
Explanation:
Single digit numbers are considered to be
strictly increasing order.
------------------------------------------------------------------------------------------
Here are some of the gears that I use almost everyday:
🖊️ : My Pen (Used in videos too): amzn.to/38fKSM1
👨🏻💻 : My Apple Macbook pro: amzn.to/3w8iZh6
💻 : My gaming laptop: amzn.to/3yjcn23
📱 : My Ipad: amzn.to/39yEMGS
✏️ : My Apple Pencil: amzn.to/3kMnKYf
🎧 : My Headphones: amzn.to/3kMOzM7
💺 : My Chair: amzn.to/385weqR
🛋 : My Table: amzn.to/3TyU2IU
⏰ : My Clock: amzn.to/3slFUV3
🙋🏻♀️ : My girlfriend: amzn.to/3M6zLDK ¯\_(ツ)_/¯
PS: While having good gears help you perform efficiently, don’t get under the impression that they will make you successful without any hard work.
Bhaiya please complete the DP playlist 🙏
I was watching the playlist and was just worried that why 1 video is hidden but as i reached upto this video it was available thanks. waiting for more.
Same here i just opened to complete the heap series and saw new video uploaded , happy to see you back bhaiya , keep up the good work. love you bhai dheeer sara
You are the best Instructor of DSA on UA-cam. I have watched all your playlists. Please make Trees playlist. PLEASEEEEEE.
Why back tracking needed here!! Clean and simple.
void Digits(String s, integer start, integer n, Array List list)
{
if (n== 0)
list add your s (after parsing them into an integer object directly.)
return;
}
for loop X from 1 to 9
Digits (s + X, X+1, n - 1 , list)
}
Can you please tell names of questions for the DP patterns you have not covered in your playlist but discussed in the first video like Fibonacci(7 questions) LIS(10 questions) Kadane's (6 questions) DP on grid(14) others(3)
Bhaiya after this playlist will you upload video on a topic tree.??
hey i have a request. in dp playlist you never made any video on longest increasing subsequence type problems. please make some videos on this pattern and how to approach this pattern please. humble request... :)
Agaya bhai dubara ❤
Finally, bro, came back🤩❤.
python code:
# Time Complexity: 9^n
def increasingNumber(n):
res = []
# handle n = 1 case explicitely
if n == 1:
res = [i for i in range(10)]
return res
vec = []
def solve(vec, res, n):
# base condition
if n == 0:
# combine vec and append to res
ans = 0
for i in range(len(vec)):
ans = (ans * 10) + vec[i]
res.append(ans)
return
# iterate over choices
for i in range(1, 10):
# controlled recursion
if len(vec) == 0 or i > vec[-1]:
vec.append(i)
# recursion call
solve(vec, res, n-1)
# backtrack
vec.pop()
solve(vec, res, n)
return res
Thanks for the explanation Aditya!
we could have taken a string instead of a vector so that we change and remove the characters at ease , below is my approach
void solve(int idx,string &str,int k,vector &res){
//base case
if(str.size()==k){
res.push_back(stoi(str));
return ;
}
for(int j=idx+1;j
King is back 😎
Thank you brother
Bhiaya sorry par mujhe aapka channel hindi me best explanation wala laga ,aur mere may be may ke baad se company aana start ho jayengi par oncapmus ke liye mujhe arrays aur strings ki series ki requirement thi , umeed aaapse hi kar rha hu please , request hai
bhaiya after this start trees thank you
Abhi isiliye channel khola tha ki bhai ko comment karte hai ki series puri kre, aur bhai ne nyi video upload kardi😊
baaki videos v bana do bhaiya 🥺. thank you.
Holy f mujhai laga bhai tapak gaya😢....Glad you're doing good 😊👍
I am very grateful to you for your videos. But the solution in this video is a bit unoptimized. We dont need a vector to store digits of the number. here is a solution
void solve(int &num, int remainingDigits, vector &ans){
if(remainingDigits == 0){
ans.push_back(num);
return;
}
int largestDigit = num%10;
//largest digit is the last digit
num *= 10;
for(int i=largestDigit+1; i
You are right!!
What's need of n=n/10. It is working fine without it also.
@@kanganabhargava1273 I am assuming you meant the code is running without num = num/10. If you look closely, in the solve function, I am passing num as pass by reference (for space optimization). It will work without num=num/10 if you use int num as pass-by-value in the solve method.
Hope this helps !
Bhaiya aap DP series complete karwa do please
and baki topics bhi le aao
also if possible then striver bhaiya wali sheet types patterns match kar sakte ho toh best not telling to copy but
love u 3000 bhaiya ❤❤
Bhai please complete dp
"9!" hoga na time complexity?
bhaiya yar thoda graph bhi padha do esake bad please and please take cses problem set graph question
did this question by myself without seeing the vid
Bhai 🤩
Welcome Again
Sir pls kindly add subtitles in dp playlist sir pls sir
❤
Bhai poori kardo please yarr ❤❤
Java Solution:
class Solution {
static ArrayList list;
public static ArrayList increasingNumbers(int n) {
list = new ArrayList();
ArrayList temp = new ArrayList();
if(n == 1){
for(int i=0; i
133 view but itne kam like ?
the real slim shady
Bro❤❤❤