Find smallest number with given number of digits and sum of digits | Greedy | DSA Sheet | Amazon 🔥
HTML-код
- Опубликовано: 12 сен 2024
- #greedy #competitiveprogramming #coding #dsa
Hey, Guys in this video I have explained with code how we can solve the problem 'Find the smallest number with a given number of digits and sum of digits'.
CODE-- ideone.com/38envp
Join our Telegram Channel for more Information
🔰 Telegram Channel Link = t.me/CodeLibrary1
🔰 Telegram Discussion Group Link = t.me/CodeLibra...
🔰 Get 10% OFF on all GeeksforGeeks Courses
Coupon Code = CODELIBRARY
🔰 Array Playlist = • Love Babbar DSA 450 Qu...
🔰 String Playlist = • Love Babbar DSA 450 Qu...
🔰 Searching and Sorting Playlist = • Love Babbar DSA 450 Qu...
🔰 Binary Tree Playlist = • Love Babbar DSA 450 Qu...
🔰 Linked List Playlist = • Love Babbar DSA 450 Qu...
🔰 Graph Playlist = • Love Babbar DSA 450 Qu...
🔰 Dynamic Programming Playlist = • Love Babbar DSA 450 Qu...
🔰 Informative Videos = • Informative Videos
🔰 Love Babbar DSA Sheet: drive.google.c...
Follow us on Instagram:
🔰 Shailesh Yogendra : / shaileshyogendra
🔰 Yogesh Yogendra : / i_am_yogesh_here
Follow us on LinkedIn:
🔰 Yogesh Yogendra : / yogesh-yogendra-26bbb518a
🔰 Shailesh Yogendra : / shailesh-yogendra-8b13...
Hope you like it. Comment if you have any doubt
LIKE | SHARE | SUBSCRIBE
Thanks
Ideas that you can do to help us.
1,Do code reviews of subscribers bro
2.which algorithm is used in which situations
Bhai you re doing one of greatest work because none of the you tuber is solving love babbar sir sheet please carry on this work one of the best RUclips channel 👍👍👍👍👍👍👍
Great explanation brother 🤞🤞🤞
this is what happens when u try to rote learn the code and explain it to someone lol so many errors in dictating the logic
Thanks, well explained :)
naaaaaaice bro love u
If u want small code
string smallestNumber(int sum, int n){
if(n*9=0;i--){
if(sum>9){
str="9"+str;
sum-=9;
}
else{
if(i==0) str=to_string(sum)+str;
else{
str=to_string(sum-1)+str;
sum=1;
}
}
}
return str;
}
🔥
if(S>9*D) return "-1";
string ans="";
while(S>0 && D>0){
if(S>9 ){
ans='9'+ans;
S-=9;
D--;
}
else{
ans=to_string(S-1)+ans;
D--;
S=1;
while(D>1){
ans='0'+ans;
D--;
}
ans='1'+ans;
}
}
return ans;
can you find error int his code??
Thus was not intuitive . But learnt something new.
Aur kya intuition chaiye bhai
Thanks a lot bro