Permutation with spaces

  Рет қаралды 86,854

Aditya Verma

Aditya Verma

Күн бұрын

Пікірлер: 266
@tanmayjadav213
@tanmayjadav213 7 ай бұрын
This playlist is still best material on youtube even after 3 years no one is able to match this level
@iqrarahmad2669
@iqrarahmad2669 16 күн бұрын
concept will always be same, so it will be top notch even after 100 years
@babbarutkarsh7770
@babbarutkarsh7770 4 жыл бұрын
I coded 100% myself and it was correct, you teach concepts which none other does. Halwa lagra hai recursion ab.
@TheAdityaVerma
@TheAdityaVerma 4 жыл бұрын
Thanks brother, do share with everybody you can !! And let's together make this channel the best channel for interview preparation on youtube, shall we? ✌️❤️
@babbarutkarsh7770
@babbarutkarsh7770 4 жыл бұрын
@@TheAdityaVerma we will for sure.
@pleasesirmorevideos4684
@pleasesirmorevideos4684 4 жыл бұрын
oh bhai khaa mat liyo
@bhaskarbhakat5689
@bhaskarbhakat5689 4 жыл бұрын
@@TheAdityaVerma linkedin hila kr rakh deya h apne... Awesome bhai
@deveshkumar2862
@deveshkumar2862 4 жыл бұрын
Can you send the code of this. I understood but I want thid code can you write the code in comments box please
@sairajdas6692
@sairajdas6692 4 жыл бұрын
I was able to code this without completing the video. I can't believe it, watching your videos really changing me. Can't thank you enough.
@tejasjhamnani7724
@tejasjhamnani7724 3 жыл бұрын
Same bro
@shashwatsingh253
@shashwatsingh253 2 жыл бұрын
Hume belive nhi ho raha ki recursive tree banane ke baad hi mai apne se code likh paya.... Thank You Aditya Bhaiya....
@vishalwagh478
@vishalwagh478 2 жыл бұрын
Till date this subset & permutation or recursion was damn tough for me.... After watching your IBH & choice diagram....Really things become easy.... You are the real geek... !!!Kudos
@samikshagupta78
@samikshagupta78 3 жыл бұрын
Your content is just fabulous! I can not express the happiness and confidence i feel after watching your videos. You are the best teacher out there. You are an inspiration. Can't thank you enough for the hardwork you do for us. Just a request.. please consider Trees, Graphs and Backtracking videos asap. PLEASE!!!
@RohitKumar-fy9fp
@RohitKumar-fy9fp Жыл бұрын
same samikhsha 🥰
@123akash121
@123akash121 3 жыл бұрын
"par samajh me zaroor aa jata hoga", haan bhai sach me samajh me zaroor aata hai, itna accha samajhaya iss pure series me ki code toh ab khud sehi likh leta hoon (par phir bhi video pura dekhta hoon, you're an awesome teacher bro)
@akashrajput3731
@akashrajput3731 4 жыл бұрын
Hey Adiya Try to make atleast one video on linked list based on recursion.........Btw thanks for providing such a awesome content
@deveshkumar2862
@deveshkumar2862 4 жыл бұрын
Can you send the code of this. I understood but I want thid code can you write the code in comments box please
@rishabsinha8749
@rishabsinha8749 4 жыл бұрын
@@deveshkumar2862 #include using namespace std; void pmt(string s,int i) { if(i == s.length()-1) { cout
@codestorywithMIK
@codestorywithMIK 4 жыл бұрын
@@deveshkumar2862 TWO APPROACHES : github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Backtracking/Split%20a%20String%20Into%20the%20Max%20Number%20of%20Unique%20Substrings
@HemanthaKumarYadav
@HemanthaKumarYadav 3 жыл бұрын
Thank God, I have found your channel! never understood recursion this well !
@souravmajumder6598
@souravmajumder6598 4 жыл бұрын
In one word, you are just awesome ❤ You make the hard things pretty easy. Take love from Bangladesh ❤🇧🇩 Waiting for Backtracking.
@BECSAQUIB
@BECSAQUIB 2 жыл бұрын
Aditya bhaiya , You have a great teaching skills. No one is providing such unique content. Thanks a billion!!!
@SnehJoshi19
@SnehJoshi19 3 жыл бұрын
Such a beautiful explaination, you made recursion like a "CakeWalk".
@p21072
@p21072 4 ай бұрын
i was able to code it up myself only because of your previous videos in which you made recursion look like such an easy topic thank you
@RadhikaAmarDesai22BCE111
@RadhikaAmarDesai22BCE111 2 ай бұрын
bhaiya sirf apki wajahse I can write recursive code like I am doing some magic. maine kabhi nahi socha tha I would be able to code this question without even seeing. I hv been struggling with recursion since 1st year. Abhi 3rd year mein sab samaj aa raha hai. Love you
@harshthakur9890
@harshthakur9890 2 жыл бұрын
maine iska code khud se kar liya...i cant believe, thank you so much bhaiya.
@codeout8529
@codeout8529 3 жыл бұрын
Your way of teaching is awesome. 5 minutes into the video and I have already coded it correctly fully myself.
@rishabsharma5307
@rishabsharma5307 6 ай бұрын
Thanks Aditya. I was able to solve this problem on my own. ``` vector result; void solve(string &str, int n, string temp) { if(n == 1) { temp.push_back(str[0]); reverse(temp.begin(), temp.end()); result.push_back(temp); return; } temp += str[n-1]; // Correctly append the character from str. solve(str, n-1, temp); temp += " "; // Add a space as a separate operation. solve(str, n-1, temp); } vector permutation(string S){ // Code Here solve(S, S.size(), ""); sort(result.begin(), result.end()); return result; } ```
@yashvirsinghnathawat1687
@yashvirsinghnathawat1687 4 жыл бұрын
We want Backtracking as well....Great Effort It really means a lot.
@RohitKumar-dz8dh
@RohitKumar-dz8dh 2 жыл бұрын
Kya kahu ab mai wo perfect word hi nahi hai mere paas apke appreciate k liye , apka recursion tree ko trace karke usko code me implement karna FAN ho gaye hum apke , pehle me recursion code ko dekhkar uska recursion tree banata tha fhir usko trace karta tha ki code kese work kar raha par usse recursion ka implementation nahi sikh paya par ab apne mujhe recursion tree banana sikha diya aur ab me khud hi implementation kar sakta hu . Charan kha hai apke guru ji 🙇‍♂️🙇‍♂️🙇‍♂️🙇‍♂️
@nrted3877
@nrted3877 3 ай бұрын
aditya bhai, god of recursion and dp
@anshulrohira882
@anshulrohira882 4 жыл бұрын
Very good content , believe me this is my first ever comment on any platform , love ur explanations , specially like the way you define patters for questions , eagerly waiting for backtracking and graph
@deveshkumar2862
@deveshkumar2862 4 жыл бұрын
Can you send the code of this. I understood but I want thid code can you write the code in comments box please
@deveshdubey6776
@deveshdubey6776 3 жыл бұрын
@@deveshkumar2862 #include using namespace std; void solve(string ip,string op){ if(ip.length()==0){ cout
@deveshkumar2862
@deveshkumar2862 3 жыл бұрын
@@deveshdubey6776 no bro it's okay thanks Yaar . I am grateful to you bro
@ryzingcode1131
@ryzingcode1131 2 жыл бұрын
I haven't seen anyone with such deep way of teaching thing.
@DidYouKnowThis.
@DidYouKnowThis. 3 жыл бұрын
This is indeed the best channel for placement preparation..U have made our lives easier with recursion ,,Thank you very much brother 🙏.
@divyanshmishra8615
@divyanshmishra8615 3 жыл бұрын
Honestly speaking brother.... recursion used to haunt me, but now i am becoming better, running my logics through these problems ..........nobody till now has explained recursion in such a depth
@sahilanand30
@sahilanand30 2 жыл бұрын
This videos are evergreen This is gonna to be remembered for centuries Mark my words People will watch this videos after centuries because this level of explanation is done only by @Aditya Verma sir
@balidinesh5687
@balidinesh5687 4 жыл бұрын
ThankYou!!!!!! so much I struggled for one month to get this type of recursion tree(ip-op)method but now I got the confidence to solve on my own.
@yadneshkhode3091
@yadneshkhode3091 3 жыл бұрын
THANK YOU BHAI khudse hi code likh liya question dekhneke baad
@yadneshkhode3091
@yadneshkhode3091 2 жыл бұрын
sabbash kachra sabbash
@pranjalck
@pranjalck 2 жыл бұрын
Gonna rock in placements if being attentive to ur playlist.. thnq.. bro!
@tempregex8520
@tempregex8520 3 жыл бұрын
Hello Aditya! thank you for starting this channel, a superb reminder that how weak are my concepts. I had a suggestion, do you mind just mentioning the runtime + space complexities at the end(not sure if you do have it in the patreon notes)? i think thats the only missing part that i found in your videos(not all of them, but some of them). Just a suggestion. Thank you for all your time and efforts in making and giving us access to this content.
@paritoshdadhich2954
@paritoshdadhich2954 3 жыл бұрын
I coded this question by myself, earlier I scared a lot while solving recursive problems. Now I getting more confident. thank you for such a great explanation. Mazza hi aagaya bhai
@mayankgautam4266
@mayankgautam4266 4 жыл бұрын
Thanks bhaiya!! When I was watching a 1st video you was saying multiple time after creating a recursive tree then code likhna will be a cakewalk :) Now a realized that after creating a recursive tree then code likhna is just like a cakewalk:-)
@ankitsoni3388
@ankitsoni3388 4 жыл бұрын
Bhai pyaar hai tu. Thanks for taking out time for all of this.
@mansimaurya4276
@mansimaurya4276 4 жыл бұрын
Please make a series on graph..Ur content is really helpful..thank u for such good explanations
@RiteshYadav-rc1np
@RiteshYadav-rc1np 3 жыл бұрын
man man man !! you are just awesome thank you for this, recursion is a cakewalk now
@himanshumehndiratta7124
@himanshumehndiratta7124 4 жыл бұрын
Kasam se sare code apne aap ho rhe hain ab. Best explantion bro.
@harjos78
@harjos78 3 жыл бұрын
Aditya you are born to teach .... hats off man!!. simply awesome
@abhigyansharma9108
@abhigyansharma9108 3 жыл бұрын
KING OF RECURSION- ADITYA SIR OP
@rishabhgupta734
@rishabhgupta734 3 жыл бұрын
re devaaaaaaa.... ae shyaam ,aditya bhai ko thank you bol...
@AnshuKumar-zn1qb
@AnshuKumar-zn1qb 3 жыл бұрын
Bhai itna easy way me recursion padha diya aapne... Thanx a lot
@tanujabharti8043
@tanujabharti8043 4 жыл бұрын
One can code only by following your explanation....no need to see code :) Great explanation!!!
@adityagore2147
@adityagore2147 Жыл бұрын
really dig the song that plays at every lecture's end 😎😎❤❤
@ishanikasingh9321
@ishanikasingh9321 3 жыл бұрын
majboori me padhna shuru kiye the, ab majaa aaraha hai ;)
@Sabudan
@Sabudan 3 күн бұрын
Best explanation ever❤
@willturner3440
@willturner3440 4 жыл бұрын
Khud se kar lia mene vo bhi bilkul sahi, thnks bhaia ab graph pr bhi video bna dijea
@AshishKumar-xg8dm
@AshishKumar-xg8dm 4 жыл бұрын
Your input.. output trick is crazy...
@sarthakbhatia7888
@sarthakbhatia7888 4 жыл бұрын
Thanks a lot man....I was just scratching my head through this question
@pulkitchausali1354
@pulkitchausali1354 3 жыл бұрын
thanky bhai helps a lot i was getting problem in starting of tree then my whole problem solved
@FrustratedEngineer_
@FrustratedEngineer_ 3 жыл бұрын
Baat toh sahi hai aapki .. Isse better koi nahi samzha sakta ..
@praphulyadav4471
@praphulyadav4471 3 жыл бұрын
bhaia you are a great teacher you made such a hard topic so easy thanku very much
@livelypooja
@livelypooja 2 жыл бұрын
Everything is good but you should give a glance to code also it helps in understanding better
@MohitGupta-ri9hf
@MohitGupta-ri9hf 4 жыл бұрын
Hey Man, Believe me, this channel is going to be the go-to choice for students!! Kudos to you and I appreciate your hard work soon you will be rewarded with millions of subscribers.
@yashgupta9677
@yashgupta9677 4 жыл бұрын
Coding God one series on backtracking please!!!!! 👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏
@Devesh121
@Devesh121 Жыл бұрын
thanku so much bhai you are gem brother bhai kam se 1 million to hona chahiye ab
@shritvaagarwal614
@shritvaagarwal614 3 жыл бұрын
now i am able to think recursively. Thank youu
@dimpleshah6538
@dimpleshah6538 3 жыл бұрын
Smooth Explanation.. I was able to write the code myself.
@varungoel6981
@varungoel6981 3 жыл бұрын
How about using char first and then appending '_' , instead of appending first '_' and then char. In this way code would become more generic and understandable. Here is my code:- #include using namespace std; void printPermutationWithSpaces(string input,int currIndex,string output){ if(currIndex == input.length()-1){ output+=input[currIndex]; cout
@shubhamjaiswal2314
@shubhamjaiswal2314 3 жыл бұрын
Isse easy koi ni samjh aa skta VERY TRUE 🤟🤟🤟🤟
@ichigo_kurosaaki
@ichigo_kurosaaki 8 ай бұрын
class Solution{ ArrayList permutations; ArrayList permutation(String S){ permutations = new ArrayList(); helper(S, S.charAt(0) + "", 1, permutations); return permutations; } void helper(String original, String permutation, int index, ArrayList result) { if (index == original.length()) { result.add(permutation); return; } helper(original, permutation + " " + original.charAt(index), index + 1, result); helper(original, permutation + original.charAt(index), index + 1, result); } }
@jain007neeraj
@jain007neeraj 4 жыл бұрын
@Aditya Did you remove Print Unique SubSet video?
@tushargogiya4017
@tushargogiya4017 9 ай бұрын
After learning last video i am able to do this question without watching current video .Above it is GFG question C++ Code class Solution{ private: void solve(string s,vector & ans,string temp) { if(s.length()==0) { ans.push_back(temp); return ; } string temp1=temp; string temp2=temp; if(temp.size()==0) { temp1+=s[0]; s.erase(s.begin()+0); solve(s,ans,temp1); } else { temp1+=' '; temp1+=s[0]; temp2+=s[0]; s.erase(s.begin()+0); solve(s,ans,temp1); solve(s,ans,temp2); } } public: vector permutation(string s){ vector ans; string temp=""; solve(s,ans,temp); return ans; } }
@aadarshtiwari3499
@aadarshtiwari3499 3 жыл бұрын
Eagerly waiting for the Backtracking playlist .
@kzr_567
@kzr_567 4 жыл бұрын
Can you please make a video on simple permutation of a string.. Im really confused how to approach it
@holy_jayden
@holy_jayden 3 жыл бұрын
What else you can do is, so that you don't need to change main() function [ insert 3 Lines of code in previous video's code ] String op1 = op; op1.push_back(ip[0]); // Line 1 String op2 = op; if(op.length() != 0) //Line 2 { op2.push_back( '_' ); //Line 3 } op2.push_back(ip[0]);
@sarthaksarangi
@sarthaksarangi Жыл бұрын
Java Solution public static void permutationWithSpaces(String s, List ans, StringBuilder op){ op.append(s.charAt(0)); if(s.length()== 1){ ans.add(new String(op)); return; } //Choices =2 //Either include the Character with space or just include the character //Including the character with a space s = s.substring(1); permutationWithSpaces(s, ans, new StringBuilder(op).append(" ")); //Not including the character with a space permutationWithSpaces(s, ans, op); }
@TulitPal
@TulitPal 3 ай бұрын
Java code to help anyone confused 😊 class Solution { TreeSet set; ArrayList permutation(String input) { set = new TreeSet(); ArrayList list = new ArrayList(); String output = input.charAt(0) + ""; if (input.length() == 1) { list.add(output); return list; } constructPermutations(input.substring(1), output); for (String ele : set) list.add(ele); return list; } private void constructPermutations(String i, String o) { if (i.length() == 0) { set.add(o); return; } String op1 = o.concat(" " + i.charAt(0)); String op2 = o.concat("" + i.charAt(0)); constructPermutations(i.substring(1), op1); constructPermutations(i.substring(1), op2); } }
@AnkushKumar-mk8ns
@AnkushKumar-mk8ns 4 жыл бұрын
Bhai backtracking ki series laoge na? Next topic kaunsa aa rha h recursion ke baad?
@ganeshmoota7349
@ganeshmoota7349 3 жыл бұрын
Java Code: public static void permutationWithSpaces(String ip,String op){ if(ip.length() == 0){ System.out.println(op); return; } permutationWithSpaces(ip.substring(1),op + ip.charAt(0)); permutationWithSpaces(ip.substring(1),op + " " + ip.charAt(0)); } public static void main(String[] args) { String ip = "ABC"; String op = ""; op += ip.charAt(0); ip = ip.substring(1); permutationWithSpaces(ip,op); }
@shivoham5939
@shivoham5939 9 ай бұрын
tc kitna hain ji is code ka
@nikitajaiswal9112
@nikitajaiswal9112 2 жыл бұрын
beginners who don't understand this series first time please watch again and again and view whole series with sequence u can able to make solution by your own.
@dhairyaanchal8623
@dhairyaanchal8623 2 жыл бұрын
This is the python code below:- def solve(input, output): if(len(input)==0): print(output) return output1=output #initialisation output2=output #initialisation output1=output1+"_" #if we include space output1=output1+input[0] #include from input output2=output2+input[0] # include from input input=input[1:] solve(input, output1) solve(input, output2) input="ABC" output=input[0] input=input[1:] solve(input,output)
@adityakumarpandey5817
@adityakumarpandey5817 3 жыл бұрын
i coded 100% myself : void solve(string ip, string op, vector&ans, int i ){ if(ip.length()==1){ ans.push_back(op); return ; } string op1=op; string op2=op; op2.insert(i," "); ip.erase(ip.begin()+0); solve(ip, op1, ans, i+1); solve(ip,op2, ans, i+2); } int main(){ string ip="ABCD"; string op=ip; vector ans1; int i=1; solve(ip,op,ans1, 1); for(int i=0; i
@hemantmarve3674
@hemantmarve3674 4 жыл бұрын
Awesome Explanation.Thank You Bhai.
@NikhilSingh-dr3ig
@NikhilSingh-dr3ig 2 жыл бұрын
If you don't want to make two extra strings in recursion and erase the string follow this: void solver(vector&ans,string sol,string s,int i) { if(i==s.size()) { ans.push_back(sol); return; } if(i
@udaypandey5659
@udaypandey5659 2 жыл бұрын
java-solution public class PermutationWithSpace { public static void main(String[] args) { String input = "ABC"; String output = ""; output = output + input.charAt(0); input = input.substring(1); permutation(input, output); } private static void permutation(String input, String output) { if (input.length() == 0) { System.out.println(output); return; } String op1= output+input.charAt(0); String op2 = output+"_"+input.charAt(0); input = input.substring(1); permutation(input, op1); permutation(input, op2); } }
@shashankmishra6705
@shashankmishra6705 Ай бұрын
how to memoize this for longer inputs. For eg. If the string len is more than 30 or 40 chars. This can throw memory limit exception.
@ayushijindal4898
@ayushijindal4898 Жыл бұрын
I have tried the question with two approaches second recursion function approach is same as discussed in the video public class PermutationSpaces { public static void printPermutationSpaces(String str, String ans) { if(str.length()==0) { ans =ans.substring(0,ans.length()-1); System.out.println(ans); return; } for(int i=0; i
@cr7johnChan
@cr7johnChan 2 жыл бұрын
vectorans; void function(string one,string S,int count,int slnt){ if(count==(slnt-1)){ ans.push_back(one); return;} count++; function(one+" "+S[count],S,count,slnt); function(one+S[count],S,count,slnt); } vector permutation(string S){ // Code Here int n =S.length(); string t=""; t+=S[0]; function(t,S,0,n); return ans; }
@Prateek_Mantry
@Prateek_Mantry 5 ай бұрын
thank you.
@Neerajkumar-xl9kx
@Neerajkumar-xl9kx 3 жыл бұрын
what else we can do is first put all spaces in between, ,then in recursive tree make decision to remove space or not...btw your video is always awesome
@_SurajGupta
@_SurajGupta Жыл бұрын
I have a doubt(please if anyone can answer) If I pass the input by reference its giving wrong answer why?
@akshitajha1209
@akshitajha1209 Жыл бұрын
Same doubt
@abhishekkapoor692
@abhishekkapoor692 3 жыл бұрын
simple ho gaya yaar....thanks bhai
@abhishekkapoor692
@abhishekkapoor692 3 жыл бұрын
@@anchaldevrani2055 email?
@vladimirputin2756
@vladimirputin2756 Жыл бұрын
public class permutationWithSpaces { // Recursive function to generate permutations with spaces. public static void helper(String input, String output) { // Base case: If the input string is empty, print the current output. if (input.length() == 0) { System.out.println(output); return; } // Take the first character from the input. char ch = input.charAt(0); // Create two branches: one with the character followed by a space, // and one without any space. String newInput = input.substring(1); String pickWithSpace = output + "_" + ch; String pickWithoutSpace = output + ch; // Recursively generate permutations for both branches. helper(newInput, pickWithoutSpace); helper(newInput, pickWithSpace); } public static void main(String[] args) { // Input string and initial output. String input = "abc"; String output = ""; // Extract and remove the first character from the input. char firstChar = input.charAt(0); output += firstChar; input = input.substring(1); // Start generating permutations with spaces. helper(input, output); } }
@easycoding591
@easycoding591 4 жыл бұрын
Brother you deserve more subscriber than love babbar
@bhaskarbhakat5689
@bhaskarbhakat5689 4 жыл бұрын
Love babbar is our guide and aditya verma is our mentor...
@rishabsinha8749
@rishabsinha8749 4 жыл бұрын
They both are good content creator and both are at their best at what they do.
@ssquare1
@ssquare1 4 жыл бұрын
Flipkart vs Amazon lol
@nishantpratapsingh3172
@nishantpratapsingh3172 4 жыл бұрын
@@ssquare1 😂😂😂
@Finn-jp6pn
@Finn-jp6pn 4 жыл бұрын
Here's the Java Code for the problem if any one needs it public static void permutationWithSpaces(String input, String output) { if(input.length() == 0){ System.out.println(output); return; } if(output.length() == 0){ output = input.charAt(0); input = input.substring(1); } String output1 = output + input.charAt(0); String output2 = output + " " + input.charAt(0); input = input.substring(1); permutationWithSpaces(input,output1); permutationWithSpaces(input,output2); }
@bairagisirfire2185
@bairagisirfire2185 4 жыл бұрын
output = String.valueOf(input.charAt(0));
@_AnuragSharma
@_AnuragSharma Жыл бұрын
Why did you leave making videos your content was so good
@kishanmishra9802
@kishanmishra9802 4 жыл бұрын
Great teacher
@yashnagda9363
@yashnagda9363 3 жыл бұрын
My python code: def solve(inp,output,original_length): #base condition(finiding output when inp is empty at leaf if len(inp)==0: print(output) return #inital case for first character. adding without space only if len(inp)==original_length: output=output+inp[0] inp=inp[1:] solve(inp,output,original_length) return output1 = output + " "+inp[0] output2=output+inp[0] inp=inp[1:] #two cases adding without space and with space solve(inp,output1,original_length) solve(inp,output2,original_length) return inp = input("enter your string!\t") output="" solve(inp,output,len(inp))
@aartikumarisingh9929
@aartikumarisingh9929 4 жыл бұрын
sir you are simply awesome!!
@aartikumarisingh9929
@aartikumarisingh9929 4 жыл бұрын
i write the whole code by myself ! thank u sooo soooo much!
@pankajkadian4623
@pankajkadian4623 4 жыл бұрын
Brother DP mai kuch aur videos aayengi ya utni hi hai?
@kumarmanish9046
@kumarmanish9046 2 жыл бұрын
I would love to know about the gear you use to create these videos. Which software and hardware you use?
@2010aishwary
@2010aishwary 4 жыл бұрын
permutations should also contain the swapping of the elements ?
@ishantjha4823
@ishantjha4823 4 жыл бұрын
Sir agr consecutive permutation only store krwane ho to kya condition lgaege?plz reply asap...
@amarjeetkumarsingh733
@amarjeetkumarsingh733 Жыл бұрын
Just Amazing....
@parvahuja7618
@parvahuja7618 5 ай бұрын
thankyou so much bhai
@krishshah5162
@krishshah5162 8 ай бұрын
bhaia why do you use return even if it is a void function??
@abhi224505
@abhi224505 3 жыл бұрын
Javascript Solution bit different than what was explained tho: function permutationWithSpaces(str) { let n = str.length; function helper(initialString, i){ if(i === n){ console.log(initialString); return ; } helper(initialString + str[i], i+1); helper(initialString + "-" + str[i], i+1); } helper("a", 1); } permutationWithSpaces("abcd");
@manishdongarekar9295
@manishdongarekar9295 2 жыл бұрын
Code in Java if helped please like import java.util.Scanner; public class Rec_Permutation_with_spaces { public static void main(String[] args) { String str =""; Scanner sc = new Scanner(System.in); str = sc.nextLine(); StringBuilder out = new StringBuilder(); out = out.append(str.charAt(0)); StringBuilder input = new StringBuilder(); input = input.append(str.substring(1,str.length())); recursion(input.toString(),out.toString()); } public static void recursion(String input,String output) { if(input.length()==0) { System.out.println(output); return; } StringBuilder out1 = new StringBuilder(output); StringBuilder out2 = new StringBuilder(output); out1.append(" "); out1.append(input.charAt(0)); out2.append(input.charAt(0)); StringBuilder inputt = new StringBuilder(input); inputt.deleteCharAt(0); recursion(inputt.toString(),out1.toString()); recursion(inputt.toString(),out2.toString()); } }
@dipuprasad9196
@dipuprasad9196 3 жыл бұрын
Thank you very much
@gauranshverma4364
@gauranshverma4364 4 жыл бұрын
headsoff to your input-output method bhai...........love U
@atharvsakhala9469
@atharvsakhala9469 3 жыл бұрын
this is a great playlist, thanks a lot! but i think recursion is incomplete without backtracking , so pls make a playlist on that too!
@nextgodlevel
@nextgodlevel 3 жыл бұрын
Python Code: def PWS(inp, out): if inp == "": print(out) return out1 = out out2 = out out1 += "_" + inp[0] out2 += inp[0] PWS(inp.replace(inp[0], ''), out1) PWS(inp.replace(inp[0], ''), out2)
Generate all Balanced Parentheses
34:03
Aditya Verma
Рет қаралды 147 М.
Permutation with Case Change | Recursion
11:17
Aditya Verma
Рет қаралды 60 М.
Ozoda - Lada ( Official Music Video 2024 )
06:07
Ozoda
Рет қаралды 25 МЛН
pumpkins #shorts
00:39
Mr DegrEE
Рет қаралды 87 МЛН
Kth Symbol in Grammar
23:32
Aditya Verma
Рет қаралды 123 М.
Count Occurrences Of Anagrams | Sliding Window
39:56
Aditya Verma
Рет қаралды 228 М.
Print unique subsets And Variations
24:48
Aditya Verma
Рет қаралды 107 М.
The math study tip they are NOT telling you - Math Olympian
7:42
Melvin Fung
Рет қаралды 592 М.
some very nice values of cosine
16:11
Michael Penn
Рет қаралды 1,5 М.
A Level Chemistry is EFFORTLESS Once You Learn This
5:30
Gradefruit
Рет қаралды 165 М.
❌ Don't Run Behind 500 LEETCODE Problems ❌ Focus on QPCD
8:31
Letter Case Permutation | Recursion
17:01
Aditya Verma
Рет қаралды 69 М.
Permutations Combinations Factorials & Probability
20:54
Mario's Math Tutoring
Рет қаралды 519 М.
Becoming good at math is easy, actually
15:29
Han Zhango
Рет қаралды 955 М.
Ozoda - Lada ( Official Music Video 2024 )
06:07
Ozoda
Рет қаралды 25 МЛН