Succesfully completed this playlist with practice on gfg , interview bit and code forces. Preaparing for offcampus internships for product base comapnies. Next playlist on backtracking and puzzles. Thanks a lot. Keep going. Helping a lot. Good wishes from PVG COET,Pune.
@@aamirhannan9245 if you are still looking for the answer, the branches are like op1 -> [use the character as such] op2 -> [change case and use the character]. Since its a number, it will only come under op1. There is no "change case" for a number. Thats why a single branch in else part which is only for the number scenario
@@aamirhannan9245Because it doesn't matter. Output 1 is just a temporary variable he stores the output in that then pushes the number into it. And then calls the recursive function with the new output. Then if the next variable in the string is an alphabet it will again divide into two cases. Lower and upper. I hope you get it now.
just listened to your question explanation and immediately wrote out the recursive function. didn't even need to think twice. halwa lag raha hain recursion the basic you've given is simply mind boggling. can't thank you enough man
@@Ishatagai12007Both are good but I am more familiar with Aditya Verma recursion and DP series so I recommend Aditya Verma. You can also prefer Strivers SDE Sheet for question practice.
@@TheAdityaVerma Great Video bro!! I already watched DP and stack but and they are really cool but still i am stuck at Trees and Graphs can you pleases provid guidance for that Thanks!!
The Input output method for generating a recursive tree is just epic..I was able to solve this question without seeing even a single minute of this video.. The way you build the concepts is just fantabulous.
thanks a lot, Bhai for this approach towards recursion problems. earlier i used to feel completely stuck. now at least i can think using the two methods to solve any recursion problem
Following this playlist from first video and now slowly slowly I don't need to see the explanation and code from the video... #RecursionIsFun Hats off to ur teaching 👍
Where I failed in code: 1)wrote 2 recursive calls for both the cases (alpha and digit) 2)in an alphabet case I just converted to upper case and did not convert to lower case 😂 But still great video 🤗🤗🔥
public class LetterCasePermutaion { static void permute(String ip,String op){ if(ip.length()==0){ System.out.println(op); return; } if(Character.isDigit(ip.charAt(0))){ String opp=op+ip.charAt(0); //include kr ke chote input kr ke recursive call krna hein ip=ip.substring(1); permute(ip,opp); } else if(Character.isAlphabetic(ip.charAt(0))){ //i dont know wheteher the character is lower case and upper case //but for one we have to add the upper case and for the other we have to add the lower case String op1=op+Character.toUpperCase(ip.charAt(0)); String op2=op+Character.toLowerCase(ip.charAt(0)); ip=ip.substring(1); permute(ip,op1); permute(ip,op2); } } public static void main(String[] args) { String ip="a1B1"; String op=""; permute(ip,op); } }
Convert the input string all into lowercase....and then also can solve the problem the way you did in the last video. just take a special condition (Only one child) in case of digits. Else two child in case of letters.
it is working on Rmr here is my code #include using namespace std; void letter_case_permutation(string ip,string op){ // base condition if(ip.size()==0){ if(op.empty()) return; cout
for javascript lovers you maybe wondering why i had used loop because javascript cannot configure directly a number inside an string so i transoform it inot an array let i = 1 function solve(inp,out){ if(inp.length == 0){ console.log(out) return; } if(typeof(inp[0]) == "string"){ let op1 = out op1 += inp[0].toLowerCase() let op2 = out; op2 += inp[0].toUpperCase() inp = inp.slice(1) solve(inp,op1) solve(inp,op2) }else{ let op = out op += inp[0] inp = inp.slice(1) solve(inp,op) } return } function main (string){ let array = [] for(let i = 0; i
Java code to help anyone confused 😊 class Solution { HashSet set; public List letterCasePermutation(String s) { set = new HashSet(); ArrayList result = new ArrayList(); constructPermutations(s.toLowerCase(), ""); for (String ele : set) result.add(ele); return result; } private void constructPermutations(String i, String o) { if (i.length()
class Solution { public List letterCasePermutation(String s) { List ans = new ArrayList(); solve(s,ans,""); return ans; } public void solve(String s , List ans , String op){ if(s.length() == 0){ ans.add(op); return; } char ch = s.charAt(0); s = s.substring(1); if(Character.isLetter(ch)){ //Convert into lowercase and call the recursive function solve(s,ans,op+ Character.toLowerCase(ch)); solve(s,ans,op+ Character.toUpperCase(ch)); } else{ // Digit encountered //Directly append into the output solve(s,ans,op+ch); } } }
bhai please start backtracking series please 🙏. placements r going on help us . and i would beg u to start on miscellaneous questions series in which u cover imp question on placements .
Succesfully completed this playlist with practice on gfg , interview bit and code forces.
Preaparing for offcampus internships for product base comapnies.
Next playlist on backtracking and puzzles.
Thanks a lot.
Keep going.
Helping a lot.
Good wishes from PVG COET,Pune.
some tips for off campus ?....
m from pune too..
Hey how are you applying for offcampus? Any suggestions?I am from Pune too😅
Can you tell the problems that you practised on Codeforces?
which playlist are you referring for backtracking
bhaiya , sach bol rha hu , kitna easy way mein explain krte ho yrr
..... keep it up
I write 100% code of above problem by myself without seeing explanation and code.
Thank you so much for playlist.
ok
Why in else case, he has only included num for case 1 and not for case 2? any idea!
@@aamirhannan9245 if you are still looking for the answer, the branches are like op1 -> [use the character as such] op2 -> [change case and use the character]. Since its a number, it will only come under op1. There is no "change case" for a number. Thats why a single branch in else part which is only for the number scenario
@@aamirhannan9245Because it doesn't matter.
Output 1 is just a temporary variable he stores the output in that then pushes the number into it. And then calls the recursive function with the new output.
Then if the next variable in the string is an alphabet it will again divide into two cases. Lower and upper.
I hope you get it now.
just listened to your question explanation and immediately wrote out the recursive function. didn't even need to think twice. halwa lag raha hain recursion
the basic you've given is simply mind boggling. can't thank you enough man
The more videos I watch of you, the bigger fan I become of you and these beautiful programming questions.
us Heena us 🥰
After print subset I didn't see a single video of recursion and I was able to solve your entire recursion playlist
thanks Bhaiya You are Elite
can u tell me whose playlist i should watch for recursion striver or aditya verma
@@Ishatagai12007Both are good but I am more familiar with Aditya Verma recursion and DP series so I recommend Aditya Verma.
You can also prefer Strivers SDE Sheet for question practice.
submitted the solution in leetcode in one go
your teaching level is awesome. thankyou so much for making recursion so easy
I like your "Chalo" 😅😅😊
Chalo !! bdiya 😂
@@TheAdityaVerma Great Video bro!!
I already watched DP and stack but and they are really cool but still i am stuck at Trees and Graphs can you pleases provid guidance for that Thanks!!
you have started loving him
@@TheAdityaVermaI like your "cool"😂
The Input output method for generating a recursive tree is just epic..I was able to solve this question without seeing even a single minute of this video..
The way you build the concepts is just fantabulous.
Did this problem myself!
Aditya bhaiya is jod!!!!!
and ofc ye leetcode ki medium problem hai ~
thanks a lot, Bhai for this approach towards recursion problems. earlier i used to feel completely stuck. now at least i can think using the two methods to solve any recursion problem
Number one skills in coding and teaching....
for python lovers :)
def permutationFind(inputs,output):
if len(inputs)==0:
print(output)
return
if inputs[0].isalpha()==True:
out1 = output
out2 = output
out1+=inputs[0].lower()
out2 += inputs[0].upper()
inputs = inputs[1:]
permutationFind(inputs,out1)
permutationFind(inputs,out2)
else:
out1=output
out1+=inputs[0]
inputs=inputs[1:]
permutationFind(inputs,out1)
return
inputs="A1B2"
output=""
permutationFind(inputs,output)
def letterCasePermutation(self, s: str) -> List[str]:
if len(s) == 1:
output = []
if not ("a"
Bro r u planning to bring videos on greedy algorithms
Your all videos are awesome,
Sandeep jain sir is a great teacher but u are absolute legend.thank you
Following this playlist from first video and now slowly slowly I don't need to see the explanation and code from the video...
#RecursionIsFun
Hats off to ur teaching 👍
@Aditya sir kya msst ho yaar, itna accha easy tareeka se shayad hin koi aur pdha skta hai. Bhat bhut msst tareeka sikhaye ho!! Thanks bro!!
@Aditya sir backtracking pe bna do video !!
Maja aaya ...
Pehle Ques samjha
Then khud se tree bana k solve kara
Phir puri video dekhi ...
positive stuffs we get in 2020,
thanx for bringing so much relives.... :-D
Thanks for the playlist sir....your explanation is extremely good.....how you are able to make things so easy...it is incredible
Very helpful, I am solving problems on leetcode without hesitation
Why are you hesitating?😂
pichhla question karne gaya tha itna sahi samjhaya ki direct yahi question kar aya 😃
I was able to write the code just after the problem statement explanation...
You are awesome !
i can say only one thing that he is underrated
Where I failed in code:
1)wrote 2 recursive calls for both the cases (alpha and digit)
2)in an alphabet case I just converted to upper case and did not convert to lower case 😂
But still great video 🤗🤗🔥
In Java :
public class LetterCasePermuatation {
private static final String[] NUMBERS = {"1","2","3","4","5","6","7","8","9","0"};
public static void main(String[] args) {
String input = "a1B2";
String output = "";
Set set = new HashSet();
solve(input,output,set);
System.out.println(set);
}
private static void solve(String input, String output, Set set) {
if(input.length() == 0){
set.add(output);
return;
}
String output1 = output;
String output2 = output;
String temp = "";
temp += input.charAt(0);
if(!Arrays.asList(NUMBERS).contains(temp)){
output1 += temp.toUpperCase();
output2 += temp.toLowerCase();
input = input.substring(1);
solve(input,output1,set);
solve(input,output2,set);
}else {
output1 += input.charAt(0);
input = input.substring(1);
solve(input,output1,set);
}
}
}
public class LetterCasePermutaion {
static void permute(String ip,String op){
if(ip.length()==0){
System.out.println(op);
return;
}
if(Character.isDigit(ip.charAt(0))){
String opp=op+ip.charAt(0);
//include kr ke chote input kr ke recursive call krna hein
ip=ip.substring(1);
permute(ip,opp);
}
else if(Character.isAlphabetic(ip.charAt(0))){
//i dont know wheteher the character is lower case and upper case
//but for one we have to add the upper case and for the other we have to add the lower case
String op1=op+Character.toUpperCase(ip.charAt(0));
String op2=op+Character.toLowerCase(ip.charAt(0));
ip=ip.substring(1);
permute(ip,op1);
permute(ip,op2);
}
}
public static void main(String[] args) {
String ip="a1B1";
String op="";
permute(ip,op);
}
}
Bro y u not uploading videos
First 1 to view .. Love your videos brother.. Please upload a playlist for Graphs and Trees :)
done myself , thanks a ton
bro,when is next video coming,eagerly waiting
Next playlist on backtracking and puzzles and on greedy algorithms
Sir aap video kyon upload ni kar rhe??
Bhai how to solve Josephus problem using IP-OP approach or IBH approach??
Wonderfully explained!
Great work brother!
Very helpful!
Thanks a lot!
Keep it up...
İs this completion of recursion or more videos are about to come.
Convert the input string all into lowercase....and then also can solve the problem the way you did in the last video. just take a special condition (Only one child) in case of digits. Else two child in case of letters.
tried another approach:
void solve(vector&res,string temp,string s,int i)
{
if(i==s.size())
{
res.push_back(temp);
return;
}
temp.push_back(char(tolower(s[i]))); //push the chsar in temp even if it is a digit
solve(res,temp,s,i+1); //recurse for next
temp.pop_back(); //pop it for backtrack
if(s[i]>=48 && s[i]
thanks for another great video. Looking forward for backtracking series.
i had faced difficulties in Recursion...but now it is clear for me...thanks a lot from my heart.....pls make more vedios....we all are with u....
class Solution {
public:
vector ans;
void Solve(string s, string &output)
{
if(s.length()==0)
{
ans.push_back(output);
return;
}
else
{
if(isdigit(s[0]))
{
string output1 = output;
output1.push_back(s[0]);
s.erase(s.begin()+0);
Solve(s,output1);
}
else
{
string output2 = output;
string output3 = output;
output2.push_back(isupper(s[0]));
output3.push_back(islower(s[0]));
s.erase(s.begin()+0);
Solve(s,output2);
Solve(s,output3);
}
}
}
vector letterCasePermutation(string s) {
string output = "";
Solve(s,output);
return ans;
}
};
can anyone look what is the problem with this code ?
class Solution {
public:
vector ans;
void Solve(string input, string output)
{
if(input.length()==0)
{
ans.push_back(output);
return;
}
if(isalpha(input[0]))
{
string op2 = output;
string op3 = output;
op2.push_back(tolower(input[0]));
op3.push_back(toupper(input[0]));
input.erase(input.begin()+0);
Solve(input,op2);
Solve(input,op3);
}
else
{
string op1 = output;
op1.push_back(input[0]);
input.erase(input.begin()+0);
Solve(input,op1);
}
}
vector letterCasePermutation(string s) {
Solve(s,"");
return ans;
}
};
Java 8 solution:
public class LetterCaseChangeRecursive {
public static void main(String[] args) {
String ip = "a1B2";
String op = "";
List output = new ArrayList();
List result = solve(ip, op, output);
result.forEach(System.out::println);
}
public static List solve(String ip, String op, List result) {
if (ip.isEmpty()) {
result.add(op);
return result;
}
String op1 = op, op2 = op;
if (Character.isDigit(ip.charAt(0))) {
op += ip.charAt(0);
ip = ip.substring(1);
solve(ip, op, result);
} else {
op1 += ip.toLowerCase().charAt(0);
op2 += ip.toUpperCase().charAt(0);
ip = ip.substring(1);
solve(ip, op1, result);
solve(ip, op2, result);
}
return result;
}
}
I am having interested in Google in one month. How should I prepare for data structure and algorithm questions
This is not working on string "RmR"...please explain
it is working on Rmr here is my code #include
using namespace std;
void letter_case_permutation(string ip,string op){
// base condition
if(ip.size()==0){
if(op.empty())
return;
cout
Sir Back-Tracking ko bhi samjao
please
class Solution:
def helper(self,s,op):
if len(s)==0:
print(op)
return
if s[0].isdigit():
op1=op+s[0]
s=s[1:]
self.helper(s,op1)
else:
op1=op+s[0].lower()
op2=op+s[0].upper()
s=s[1:]
self.helper(s,op1)
self.helper(s,op2)
easy! did in one go
Bhai new video nhi ayi
Aur v vedios aa rahe hai is playlist me ???
Bhaiya next video kb aaegi
make videos on these questions
*> Replace Pi with digits
Input : str = “pippppiiiipi”
Output : 3.14ppp3.14iii3.14
Input : str = “pip”
Output : 3.14p
Input : str = “xpix”
Output : x3.14x
*> String to integer conversion recursive
isme string matching lagegi.. KPM se ho jaega..
We can simply convert the entered string in lowercase and solution will be same as previous video
Brother yrr video banani start kardo wapas kitna aur wait karna padega
Recursion is beautiful and magucal
Maybe you can show us to solve basic DP problems (not covered in DP series) with recursion to build up the concept.
simple code :
#include
using namespace std;
char lowercase(char ch)
{
if(ch>=97 && ch=65 && ch
class Solution {
public:
void solve(string s,int index,vector&ans,string output){
if(index==s.size()){
ans.push_back(output);
return;
}
//including the letters
if((s[index]>='a' && s[index]='A' && s[index]
backtracking and graph and DP ki playlist complete kardo bhaiya plzz!
def solve(output, s):
if len(s) == 0:
print(output)
return
else:
if s[0].isalpha():
solve(output + s[0].lower(), s[1:])
solve(output + s[0].upper(), s[1:])
else:
solve(output + s[0], s[1:])
s = "a1B2"
output = ""
solve(output, s)
for javascript lovers
you maybe wondering why i had used loop
because javascript cannot configure directly a number inside an string
so i transoform it inot an array
let i = 1
function solve(inp,out){
if(inp.length == 0){
console.log(out)
return;
}
if(typeof(inp[0]) == "string"){
let op1 = out
op1 += inp[0].toLowerCase()
let op2 = out;
op2 += inp[0].toUpperCase()
inp = inp.slice(1)
solve(inp,op1)
solve(inp,op2)
}else{
let op = out
op += inp[0]
inp = inp.slice(1)
solve(inp,op)
}
return
}
function main (string){
let array = []
for(let i = 0; i
Why in else case, he has only included num for case 1 and not for case 2? any idea!
Is the recursion playlist completed or are more videos coming?
Bhaiya graphs ki playlist ka plan hai koi future me?
Bhai plan sbka to sbka hai !! pr aadmi ek aur data structures anek !!
Most probably next will backtracking and then graphs.
@@TheAdityaVerma bhaiya subscribers bhi to anek honge ek din!!!!
@@TheAdityaVerma bro tu bhagwan ka bheja hua farista hai. bhai tu padhata nai h tu aag laga deta hai.
Java code to help anyone confused 😊
class Solution {
HashSet set;
public List letterCasePermutation(String s) {
set = new HashSet();
ArrayList result = new ArrayList();
constructPermutations(s.toLowerCase(), "");
for (String ele : set) result.add(ele);
return result;
}
private void constructPermutations(String i, String o) {
if (i.length()
Bhai aap baki data structure ka bhi banaoge na? Like linked List, trees and all?
Java Code:
class Solution {
public List letterCasePermutation(String s) {
String ip = s;
String op = "";
List res = new ArrayList();
solve(ip, op, res);
return res;
}
public void solve(String ip, String op, List res){
if(ip.length() == 0){
res.add(op);
return;
}
if(Character.isAlphabetic(ip.charAt(0))){
String op1 = op;
String op2 = op;
op1 += Character.toLowerCase(ip.charAt(0));
op2 += Character.toUpperCase(ip.charAt(0));
ip = ip.substring(1);
solve(ip, op1, res);
solve(ip, op2, res);
}
else{
String op1 = op;
op1 += ip.charAt(0);
ip = ip.substring(1);
solve(ip, op1, res);
}
}
}
Bro ab complex problems daala kro , u r amazing.
Where are you nowadays,like can't see your recent videos
Bhaiya thanks you , i love u 3000
already solved this one too
JAVA CODE:-
public class Main {
public static void main(String[] args) {
String str="a1B2";
String op="";
plc(str,op);
}
static void plc(String str,String op)
{
if(str.length()==0)
{
System.out.println(op);
return;
}
if(Character.isDigit(str.charAt(0)))
{
plc(str.substring(1), op+str.charAt(0));
return;
}
plc(str.substring(1), op+""+str.toUpperCase().charAt(0));
plc(str.substring(1), op+""+str.toLowerCase().charAt(0));
}
}
Agar Aditya bhai graph and tree daal dete u tube par sabhka kaam khatam ho jataa 🤣🤣🤣🤣
Sir, Greedy Algorithms and Divide and Conquer ki bhi playlist banado...pleassseeeeee!!!!
bhaiya apne company me referrel dijiega?
Gaurav, bhai one doubt in recursion some time we loop on the string some time we put two recursive call. How to decide?
class Solution {
public List letterCasePermutation(String s) {
List ans = new ArrayList();
solve(s,ans,"");
return ans;
}
public void solve(String s , List ans , String op){
if(s.length() == 0){
ans.add(op);
return;
}
char ch = s.charAt(0);
s = s.substring(1);
if(Character.isLetter(ch)){
//Convert into lowercase and call the recursive function
solve(s,ans,op+ Character.toLowerCase(ch));
solve(s,ans,op+ Character.toUpperCase(ch));
}
else{ // Digit encountered
//Directly append into the output
solve(s,ans,op+ch);
}
}
}
Divide n conquer based problems ki playlist plzzz bhai
please explain this question Find Maximum number possible by doing at-most K swaps
code:
class Solution {
void solve(vector &ans, string s, string S){
if(!s.length()) {ans.push_back(S); return;}
S=s.back() + S;
s.pop_back();
solve(ans, s, S);
if(!isdigit(S[0])) {S[0] ^= ' ';
solve(ans, s, S);}
}
public:
vector letterCasePermutation(string s) {
vector ans;
string S="";
solve(ans, s, S);
return ans;
}
};
Bhaiya please video upload krdo graph pr bilkul 0 se...
Can anyone share the problem link?
Please make videos on tilling problem
Python Code:-
def solve(input,output):
if(len(input)==0):
print(output)
return
if input[0].isalpha()==True:
output1=output
output2=output
output1+=input[0].lower()
output2+=input[0].capitalize()
input=input[1:]
solve(input,output1)
solve(input,output2)
else:
output1=output
output1+=input[0]
input=input[1:]
solve(input,output1)
return
input="a1B2"
output=""
solve(input,output)
Need to find only unique strings.In main function we need to use map and print only unique strings
Anybody seeing this vdo In 2022 and why aditya sir do not posting any video...
How to generate all the permutations of a string? Can you please make a video on this problem using I/p O/p method
thank you.
Is the recursion playlist over ?
Bhai aap graphs start kr skte hai pls?
Bhai great explanations as usual.
What about extended input output method problems?
I tried becoming a patron of you but payment only through credit card .. can you add payment through debit card as well!
how to compute normal permutations with this method
Sir yeh question ka approach kya hai
Print all combinations of factors in C.
class Solution {
public:
void dfs(string& s, vector& res, string curr, int i) {
if(curr.length() == s.length()) {
res.push_back(curr);
return;
}
char c = s[i];
if(isalpha(c)) {
// left: small
string lcurr = curr;
lcurr.push_back(tolower(c));
dfs(s, res, lcurr, i + 1);
// right: caps
string rcurr = curr;
rcurr.push_back(toupper(c));
dfs(s, res, rcurr, i + 1);
} else {
curr.push_back(c);
dfs(s, res, curr, i + 1);
}
}
vector letterCasePermutation(string s) {
vector res;
string curr;
dfs(s, res, curr, 0);
return res;
}
};
very helpfull ....plz make an video on how to calculate space complexity of any program in any language?
bhai Edit distance aur Bursting Baloon ka bhi video daal do mko tushar roy ka video nhi dekhna😂😂
@aditya verma please reply recursion ki playlist khatam toh nhi hui naa abhi? aur videos kab aenge?
more videos to come !! soon !!
@@TheAdityaVerma backtracking?
bhai please start backtracking series please 🙏. placements r going on help us . and i would beg u to start on miscellaneous questions series in which u cover imp question on placements .
"Jedi" 🤩🤩
Bhaiya , we can change the input given to us into all small cases by looping on it 😅😅😁😁