Recursion in One Shot | 9 Best Problems

  Рет қаралды 1,036,856

Apna College

Apna College

Күн бұрын

Пікірлер: 685
@prabhusingh7481
@prabhusingh7481 3 жыл бұрын
The title of the video is so aptly named and the instructor is very clear on the fundamentals and doesn't shy away from enumerating all the possibilities to help the student visualize the problem. Hats off to the effort you have put in making such an obscure topic so tangible. Looking forward to more videos on this series.
@shashwatsingh479
@shashwatsingh479 2 жыл бұрын
Can you provide me with the 1st part of this video plz.
@minaalkhajuria8681
@minaalkhajuria8681 Ай бұрын
Placement kaisa rha fir???
@jayprakashkumar4492
@jayprakashkumar4492 Ай бұрын
😂😂😂​@@minaalkhajuria8681
@stable577
@stable577 Жыл бұрын
33:06 (logic of initializing idx=-1 ), 47:46(array sorting code can be optimized)
@theunknown5787
@theunknown5787 10 ай бұрын
i think there is some sort of mistake in problem no. 3, let's assume we had passed string as "bab" here when it check for first it will only modify first, because you have give last as the else statement... Even though it's output should be first - "1 index" and last- "1 index", it will be first -"1 index" and last as "-1 index ( initialised value )" solution - you can just add last=first in the if loop, i think that solves it
@premnarain8077
@premnarain8077 2 жыл бұрын
# TOWER OF Hanoi # Python Version def tower_of_hanoi(n,src,helper,dest): if (n==1): print("Transfer Disk {0} from {1} to {2}".format(n,src,dest)) return tower_of_hanoi(n-1,src,dest,helper) print("Transfer Disk {0} from {1} to {2}".format(n,src,dest)) tower_of_hanoi(n-1,helper,src,dest) tower_of_hanoi(3,"S","H","D") Thanks for nice explaination.
@anvesha_prakash
@anvesha_prakash 2 ай бұрын
thnks
@reshihashim4094
@reshihashim4094 3 жыл бұрын
Amazing ... just amazing 🔥🔥 got each bit of it... the most important problems of recursion... widened my view over recursion... Thank u soooOoo muchhh for such an amazing lecture.... love from Kashmir ❤️
@prabhu5220
@prabhu5220 Жыл бұрын
Can't thank you enough for this video , this video made me get less anxious about recursion . thank you so much!!
@adityabhatt4177
@adityabhatt4177 7 ай бұрын
looked 4 different videos then came here for the tower of hanoi problem and understood it in one go amazing...just amazing
@anwarbasha5073
@anwarbasha5073 7 ай бұрын
if you understand can you explain me this one please
@abhijith7131
@abhijith7131 5 ай бұрын
@@anwarbasha5073 watch the vedio of tap academy on tower of hanoi.They explained it very well graphically.
@nubguy8219
@nubguy8219 Ай бұрын
Same man really clear here
@haritmishra3798
@haritmishra3798 3 жыл бұрын
aapke saari videos mere future mai most probably help karne wali hai..so thanks in advance.....ab coder banna hai and mba grad se jyaada paise kamane hai
@manojtomar697
@manojtomar697 Жыл бұрын
Such an interesting and easy method of teaching the hard topic with ease.Great !
@vrgamerz12
@vrgamerz12 2 жыл бұрын
Dii, you are so great teacher.. i saw java placement playlist and i understand java very well thank you very much.😇
@subhammishra316
@subhammishra316 3 жыл бұрын
Thanx a lot , the lecture from c++ course was very difficult to cope up with👍👍😊
@guddubhaiya288
@guddubhaiya288 3 жыл бұрын
Thank you Microsoft wali didi & also OP🙏🙏😊😊😊
@hari8568
@hari8568 3 жыл бұрын
Really nice explanation of tower of Hanoi problem 👍👍
@satyamgupta-b8e
@satyamgupta-b8e 9 ай бұрын
nhi aya bhai
@arthurlewin1952
@arthurlewin1952 3 жыл бұрын
The way aman bhaiya response to feed backs is awesome like recursion part was not so well explained in the cpp course but here we are
@tilakjilka6446
@tilakjilka6446 3 жыл бұрын
yeah definately, i was really stucked at cpp playlist after recursion . But here it is.....
@hustlewithnik
@hustlewithnik 2 жыл бұрын
Thankyou for building logic and intution for such an difficult topic.VERY MUCH CLEAR AND ABLE TO SOLVE QUESTIONS ALSO.. You are amazing❤️❤️❤️
@striderar7813
@striderar7813 2 жыл бұрын
30:00 For a better understanding of how stacks are implemented while using recursion, use this: public class Main { public static void printRev(String s, int x=0){ if(x==s.length()){ return; } printRev(s, x+1); System.out.print(s.charAt(x)); } public static void main(String[] args) { String s="abcd"; printRev(s, 0); } }
@mythicsumanyt4078
@mythicsumanyt4078 2 жыл бұрын
Tqs bruh
@ayushparikh9209
@ayushparikh9209 3 жыл бұрын
Wow I didn't know it before that god "Brahma Ji" himself created tower of Hanoi algorithm ! 🙄 1:04
@swatimaheshwari9730
@swatimaheshwari9730 2 жыл бұрын
MY APPROCH FOR MOVING ALL "X" TO END OF THE STRING: public static void shiftExToEnd(StringBuilder str, int i){ if(i==str.length()-1){ System.out.print(str); return; } if(str.charAt(i)=='x'){ str.delete(i, i+1); str.append("x"); } shiftExToEnd(str, i+1); }
@GOD__
@GOD__ 2 жыл бұрын
Delete ki jagah substring bhi use kar sakte ho
@muzammilansari381
@muzammilansari381 Жыл бұрын
this code is give wrong output in some cases
@subham5267
@subham5267 2 ай бұрын
41:11 - Check if the array is sorted (strictly increasing) public class arr_sorted { public static boolean arr_sort(int arr[], int ind){ if (ind == arr.length) { return true; } if (arr[ind]==ind+1) { return arr_sort(arr, ind+1); }else{ return false; } } public static void main(String[] args) { int arr[]= {1,2,3,4,5,5}; System.out.println(arr_sort(arr, 1)); } }
@Anonymous-qr5pz
@Anonymous-qr5pz 2 жыл бұрын
Thanks for such great explanation. Now I am pretty much comfortable in recursion. You are doing a great job.
@AKJ00829
@AKJ00829 Жыл бұрын
Are you a school student?
@codexamofficial
@codexamofficial 2 жыл бұрын
19:43 __ I appreciate your effort but you did some mistakes 1. Base case - why for 1 disk it will for zero our program can run for 1 disk also so base case will be -> if(n == 0) { return; } 2. Parameters - Passing parameter will be S D H instead of S H D like -> towerOfHanoi(n, "S", "D", "H"); now, this is the right sequence (*You can visualize and relate with lecture also)-> transfer disk 1 from S to D transfer disk 2 from S to H transfer disk 1 from D to H transfer disk 3 from S to D transfer disk 1 from H to S transfer disk 2 from H to D transfer disk 1 from S to D
@codexamofficial
@codexamofficial 2 жыл бұрын
@peanutButter if I pass S H D in this program This will return transfer disk 1 from S to D transfer disk 2 from S to D transfer disk 1 from D to H transfer disk 3 from S to H transfer disk 1 from H to S transfer disk 2 from H to S transfer disk 1 from S to D Where S is src and H is helper nd D is Destination I said to visualize the output: disk 1 first goes from S (source) to D (destination), and then disk 2 will go from S (source) to H (helper), and then again disk 1 will go from D(destination) to H(helper)...nd so on this is the correct sequence... When S H D is passed as it is, the output format changes also sequence and you can see that the new output is disk 2 transfer S(source) to D(destination) where this will be the output disk 2 transfer S(source) to H (helper).
@vikastiwari8909
@vikastiwari8909 9 күн бұрын
Such a good explanation ever seen this youth really need teacher like u🎉🎉🎉🎉
@AakshitaSingh
@AakshitaSingh 9 ай бұрын
There is an error for the question - First and Last Occurrence using Recursion, the method you stated is suitable when the first and last occurence is different but if there is only one occurence then it fails to give the right answer as it gives -1 for the last occurrence. Here is the corrected code: if (str.charAt(index) == c) { if (first == -1 && last == -1){ first = index; last = index; } else last = index; }
@shifteditz06
@shifteditz06 3 ай бұрын
54:00 short and better approach. This code will work for any input character public static void transferCharacters(String str, char ch, int index, String helperString, String moveAllchars){ // helperString will store all the cahracters other than ch // moveAllchars will store all the occurances of that particular character if(index < str.length()){ if(str.charAt(index) == ch) transferCharacters(str, ch, index+1, helperString, moveAllchars + ch); else transferCharacters(str, ch, index+1, helperString + str.charAt(index), moveAllchars); } else{ System.out.println("new string of all transferred " + ch + " " +(helperString + moveAllchars)); return; } PS : also, time complexity is minimum in this code O(n) without roundoff or ignoring some integer
@spritualgamer5122
@spritualgamer5122 Жыл бұрын
The way of teaching is incredible 🎉
@prashantMishra-it2im
@prashantMishra-it2im 3 жыл бұрын
This is the best way to explain which builds intuition and logic...thank u so much for your efforts 😇😇
@computer5548
@computer5548 3 жыл бұрын
kzbin.info/www/bejne/qoHEm2ihe5mfaas
@ShivamKumar-zj8bp
@ShivamKumar-zj8bp 3 жыл бұрын
Didi please make a full course on android devlopment begeniers to advance with real life project 🔥🔥🔥
@sujeethgorati7062
@sujeethgorati7062 3 жыл бұрын
Exactly bro.
@abhilashhadagali5572
@abhilashhadagali5572 3 жыл бұрын
Haa really we need this
@MO-fg2cm
@MO-fg2cm 3 жыл бұрын
Go find some other courses ... Don't wait for them to do ..
@Mohit-dk4jx
@Mohit-dk4jx 3 жыл бұрын
Yes we need such courses
@ajay-iy4xb
@ajay-iy4xb 2 жыл бұрын
I want also bro
@avanish_shaw
@avanish_shaw 6 ай бұрын
my mind suffered in pain after listing to the first explaination of tower of hanoi
@shifteditz06
@shifteditz06 3 ай бұрын
59:20 you can also use java builtin String method .replaceAll() to replace all the occurances of a character with a new character public static void removeDuplicates(String str, String newStr, int index){ // newStr will only store unique characters if(index < str.length()){ if(str.charAt(index) != '#'){ newStr += str.charAt(index); /* before replacing, first of all we will convert that particular character into string * (as replaceAll will only accept (String, String) as arguments */ str = str.replaceAll(String.valueOf(str.charAt(index)), "#"); removeDuplicates(str, newStr, index+1); } else removeDuplicates(str, newStr, index+1); } else{ System.out.println("new String : "+newStr); return; } } PS : for someone who have question that what if string contains '#' as character. As per question and solution which she has written String only contain alphabets
@sachinsoma5757
@sachinsoma5757 2 жыл бұрын
This video helped me understand Tower of Hanoi clearly, thanks for the tutorial
@subhabratabasu9804
@subhabratabasu9804 2 жыл бұрын
I am an it professional and still I watch your videos... They are helpful to relearning things
@digi_aayu
@digi_aayu 8 күн бұрын
You should not call urself a professional then😂
@niteshsingh-ii5hx
@niteshsingh-ii5hx 2 жыл бұрын
loved this video ! cleared all doubts on recursion.
@SONIC_6
@SONIC_6 7 ай бұрын
! Cleared or its cleared 😂
@shrutisah786
@shrutisah786 10 ай бұрын
we can also do the program at 48:50 by this code public class program15 { public static void move(StringBuilder str, int idx){ if(idx==str.length()){ System.out.println(str); return; } if(str.charAt(idx)=='x'){ str.deleteCharAt(idx); str.append('x'); move(str, idx+1); } else{ move(str, idx+1); } } public static void main(String[] args) { StringBuilder str = new StringBuilder("abcdxxx"); move(str, 0); }
@aryasharma69
@aryasharma69 5 ай бұрын
there can be multiple ways to solve a problem, since it is a recursion class and your code does not contain any recursive method, so it is wrong from the recursion prespective
@Rana_Umesh
@Rana_Umesh 2 жыл бұрын
Ma'am sacchi aap bhut accha pdati hooo mja aa jata hai ek baar mai h topic clr hoo jate hai bs aap ds algo using java ki classes or lelijye
@nitishbagdiiiitu6779
@nitishbagdiiiitu6779 Жыл бұрын
Didi what an explaination !!! amazed but first question concepts is not mythology we are proud to be Hindu jai shree Ram
@velocityvibezzz
@velocityvibezzz 10 ай бұрын
Thanks so much. I learned so much about recursion through this and the previous video.
@YUDDHYASWA
@YUDDHYASWA 3 ай бұрын
Thanks ma'am,❤ I am very grateful to you, for you making me understand complex programs and also making me do the hardwork.willingly, due to your quality of teaching.
@sudhanshuroy9673
@sudhanshuroy9673 3 жыл бұрын
You take index of string from 0 to string.length() But I think it should be from 0 to String.legth -1 and we cover every char of string
@felix_72
@felix_72 Жыл бұрын
right
@PiyushAnand-td3fl
@PiyushAnand-td3fl 11 ай бұрын
@@felix_72 i had the same doubt as she took array.length-1 in the next problem
@kasifmansuri7552
@kasifmansuri7552 Жыл бұрын
as alpha student this video still helps alot Thanks Shraddha mam
@pankajsingh-cn3ec
@pankajsingh-cn3ec 2 жыл бұрын
New Approch or My Approch : first of all mam u r an awesome teacher . Please let me know what i m thinking us better or not. Ques. Remove duplicate string. My perception-> In this as per your code every time we have to check every element for atleast 26 times. But we can get new array string[e.g->New_array] which is empty and then we compare it from out input char one by one if the char is not available we will add it and then again we compare next char from New_array and add if its already not availabe. In this method we don't have to compare it 26 time for every elements until we got last 26th element (for which also we have to compare it for once only because we out New_array length got length of 26 we will return and close the program ).And you told its time complexity is O(n) but its comparing every element atleast for 26 time so its complexity should be O(n square ) or something else which i don't know (as i have started this topic today only ). Please let me know i m correct or not. Also we doesn't require bool array. #memorysave #issue #complexity #tle #timelimitexced #AmanBhaiyaop #AmanBhaiyaThankYou #thankyoudi
@shashwatsingh479
@shashwatsingh479 2 жыл бұрын
Can you provide me with the 1st part of this video plz.
@lost2932
@lost2932 10 ай бұрын
56:08 by the folllowing code we don't have to use the loop at the end, will this result in a better time complexity? public static String elString = ""; public static String newString = ""; public static void moveAtEnd( String str , int idx, char el){ if(idx == str.length()){ newString = newString + elString; System.out.println(newString); return; } if(str.charAt(idx) == el){ elString = elString + el; } else{ newString = newString + str.charAt(idx); } moveAtEnd(str, idx + 1 , el); }
@kamaleshwaran5802
@kamaleshwaran5802 4 ай бұрын
Still the time complexity would be the same i think
@Rex-j1q
@Rex-j1q 2 ай бұрын
@@kamaleshwaran5802 but still better than using for loop
@devangseksaria4888
@devangseksaria4888 2 жыл бұрын
45:54 why are putting return after calling the isSorted function again??
@hishrey
@hishrey 5 ай бұрын
Thank u so much mam i had to clear the phone combination problem which i was stuck at from a long time.... and now it is clear to me by your valuable way of teaching....😊
@aimanayyaz8957
@aimanayyaz8957 4 ай бұрын
Can you explain me the dry run of keypad combination
@misbashaikh3357
@misbashaikh3357 Жыл бұрын
My fear for recursion all gone . thank you.i am literally enjoying it now 😊❤
@pawangawale9053
@pawangawale9053 7 ай бұрын
My Fav Question Was TowerOfHanoi, Find Occurance & Print Keypad Combination 😊
@randomvivek_
@randomvivek_ 2 ай бұрын
Last one was tough to understand without getting the concept of oops first. this video is sure tough for beginners who's giving efforts but still not in right order
@archanasoni9832
@archanasoni9832 3 жыл бұрын
First que kitna easy hai par uska itna easy tarike se samjaya ki aisa laga 2 no. Ko plus krna hai bohot ache se explain krti hai didi or aman bhaiya is course mai jlde video apload kro daily ek
@Shriram-y9v
@Shriram-y9v Ай бұрын
In Occurance of an element code problem if their is only one 'a' then last print -1🤖
@balasagargoud326
@balasagargoud326 2 жыл бұрын
40:05 What if there is only 1 element present in the string what we are searching for ,then first and last indexes should be same ,but form this code we get first index value correct but last index value as -1. So update last index value in both if and else condition then we ill get correct ans.
@ucm269
@ucm269 2 жыл бұрын
Nice catch @Balasagar Goud
@supratiksarkar1195
@supratiksarkar1195 2 жыл бұрын
This is a much better code to reverse a string. Taken from - A Common Sense Guide to DSA public class chk { public static String reverse(String s) { if(s.length()==1) { return s; } return reverse(s.substring(1,s.length()))+s.charAt(0); } public static void main(String[] args) { String s="hanuman"; System.out.println(reverse(s)); } }
@AmarKumar-nf3nn
@AmarKumar-nf3nn Жыл бұрын
Same code is given in the notes of this lecture
@bhupendradixit3308
@bhupendradixit3308 2 жыл бұрын
If input string is "abcd" , your code will print first as 0 and last as -1 So, you need to assign first and last both with idx value inside if condition. And later last variable will be updated inside else if more occurances are there of the character 'a'.
@ayushanand9718
@ayushanand9718 2 жыл бұрын
True that. Nice observation. Thanks.
@rachitmathur1486
@rachitmathur1486 2 жыл бұрын
Buckup Girl, you are the combined force of Goddess Parvati-Laxmi-Saraswati👍👍👍
@mr.detecto1955
@mr.detecto1955 Жыл бұрын
Python recursive code for reversing string: string = input("enter string: ") index = len(string)-1 def rev_str(index, string): if index==0: print(string[index]) return else: print(string[index], end="--->") rev_str(index-1,string) # calling the function rev_str(index,string)
@abhaykonge969
@abhaykonge969 2 жыл бұрын
Didi is the best 😊 I means 'ek number' 👍
@biplabsarkar1959
@biplabsarkar1959 Жыл бұрын
1:03:40 how ma'am include that newString is male and string is female?
@alakhshukla7553
@alakhshukla7553 2 жыл бұрын
20:01 Tower of Hanoi problem:- when n=2; why the 2nd step is transferred disk 1 from S toD not disk 2 transfer S to D .
@tysonelliot2591
@tysonelliot2591 Жыл бұрын
In occurrrance of the element in the string problem ,I think the code will not work properly in some cases where a element has occurred only once in the String.
@athulbabu8425
@athulbabu8425 Жыл бұрын
Add last=idx also in the first ==-1 if
@kalpitbansal9923
@kalpitbansal9923 5 ай бұрын
I think at 39:12 its if(idx == str.length() -1) because we idx starting from 0 so we need to go till last index that is str.length()-1
@mansoorahmad5774
@mansoorahmad5774 3 жыл бұрын
Best Recursive Explanation is at 56:55 "in the bottom right corner". xdxd
@computer5548
@computer5548 3 жыл бұрын
kzbin.info/www/bejne/qoHEm2ihe5mfaas
@khanfahad8289
@khanfahad8289 3 жыл бұрын
Good teacher you all 👌👌👌
@shanmugampoojan6412
@shanmugampoojan6412 3 жыл бұрын
I love this channel....❤️
@shwetanksudhanshu4383
@shwetanksudhanshu4383 2 жыл бұрын
Thanks very much for your efforts.🙂
@veatrtwin8870
@veatrtwin8870 3 жыл бұрын
How to calculate the number of steps needed for n disk in Tower of Hanoi n = 1 then step = 1 + 2 = 1(1 is from above step) + 2 (2 is the number needed to add with 1 to get 3) = 3 the above step can also be written as 2 ^ n-1 n = 2 then step = 3 + 4 = 3(3 is from above step) + 4 (4 is the number needed to add with 3 to get 7) = 7 the above step can also be written as 2 ^ n-1 + 2 ^ n-2 n = 3 then step = 7 + 8 n = 4 then step = 15 + 16 n = 5 then step = ? n = 1 then step = 1 = 2 ^ n-1 = 2 ^ 1-1 = 2 ^ 0 = 1 steps n = 2 then step = 3 = 2 ^ n-1 + 2 ^ n-2 = 2 ^ 2-1 + 2 ^ 2-2 = 2 ^ 1 + 2 ^ 0 = 2 + 1 = 3 steps n = 3 then step = 7 + 8 n = 4 then step = 15 n = 5 then step = ? when n = 4 = 2 ^ 3 + 2 ^ 2 + 2 ^ 1 + 2 ^ 0 = 8 + 4 + 2 + 1 = 15 step when n = 4 if you didn't understand then docs.google.com/document/d/1Jr0ai4ADbLVvi4-FVURU5qsilL4zybOiAPT14PgyASA/edit?usp=sharing Hope you understand now ^_^
@TasniaSharin
@TasniaSharin Ай бұрын
This video problem should be seen by those who are coding basic level. I just learn recursive
@guddubhaiya288
@guddubhaiya288 3 жыл бұрын
Didi pls take live class for C++ programming pls didi😊😊😍😍😍
@mdareefuddin2196
@mdareefuddin2196 5 ай бұрын
Excellent teaching on recursion mam
@brajeshkumar462
@brajeshkumar462 2 жыл бұрын
Thanku sister free me coding shikhane ke liye
@anubratadeb603
@anubratadeb603 11 ай бұрын
at 56:52 we can solve this using loop public class Test{ public static void main(String[] args){ String str = "abbccda"; String newStr = ""; for(int i=0; i
@AK-hz4li
@AK-hz4li 2 жыл бұрын
1:13:52 can anyone pls explain "subsequence using recursion" with MEMORY STACK VISUALISATION
@vivek80441
@vivek80441 Жыл бұрын
I also not understand these two call
@mirzamohammadabbas2221
@mirzamohammadabbas2221 2 жыл бұрын
Another way for question 6 without use of boolean array Hope it helps import java.util.*; public class MBrenXI10 { static Scanner sc = new Scanner(System.in); public static void convert (String blank, String d, int n, int x){ int count = 0; if (n==x){ System.out.println(blank); return; } else { for (int i = 0; i
@devanshprajapati3289
@devanshprajapati3289 3 жыл бұрын
Can you please explain what heppen at memory for 01:05:50 Print all subsequences questions? i want to back track this question by how code call.....
@devanshprajapati3289
@devanshprajapati3289 3 жыл бұрын
Please explain code briefly....
@ashu3128
@ashu3128 2 жыл бұрын
@@devanshprajapati3289 now its been 8 months bro,if u got it then plz explain to me too,i wud be grateful..
@priyanshuvettori5179
@priyanshuvettori5179 2 жыл бұрын
Yaar kitna achaa padhaati hai didi 😍
@suryakumararun5761
@suryakumararun5761 2 жыл бұрын
Can anyone explain that in 37:06 why we are declaring first and last as static variables and not as parameters of the function.... *I tried it as parameters and it is working just fine then why static variables?*
@mehakarora3977
@mehakarora3977 2 жыл бұрын
Chk this video from 36:33 than ur doubt is clr 😊
@ranvijaypatel3213
@ranvijaypatel3213 8 ай бұрын
There is some mistake in FirstAndLast Occurrence Question: Here is the correct code -> static int first = -1; static int last = -1; public static void firstAndLast(String str, int index, char element) { if(index == str.length() ){ System.out.println("First: "+first + " Last: "+last); return ; } if(str.charAt(index)==element && first==-1){ first = index; last = index; }else if(str.charAt(index)==element){ last = index; } firstAndLast(str, index+1, element); }
@Keeks_08
@Keeks_08 11 ай бұрын
Your videos are truly wonderful, but could you kindly assist us by including English subtitles? It would greatly benefit those who may not understand Hindi.
@ssk7690
@ssk7690 2 жыл бұрын
In first and last occurence, if(first== -1) { first = index; last = index; } else last = index; Otherwise if a string has target char once it'll show -1 for last occurence which is not true
@KhalandarNawalSheikh
@KhalandarNawalSheikh 10 ай бұрын
if(first== -1) { first = index; } last = index; else is not required only.
@jaikumarm6964
@jaikumarm6964 Жыл бұрын
great video ,explanation is neat and understandable
@amansayyad7286
@amansayyad7286 3 жыл бұрын
At 1:14:05 didi ne likha System.err.println for base case still we get the output how ?
@abhijeetdhumal8650
@abhijeetdhumal8650 2 жыл бұрын
because err and out both are from output string. err use for error function
@starkendeavours7072
@starkendeavours7072 2 жыл бұрын
#30:00 another solution can be by returning the reverse string itself instead printing. public class recursion { public static String reverse(String s, int idx, String str){ if(idx < 0){ return str; } str = str + s.charAt(idx); return reverse(s, idx - 1, str); } public static void main(String[] args) { String s = "abcd"; int idx = s.length() - 1; String x = reverse(s,idx, ""); System.out.println("Reverse: " + x); } } #1:04:38 I did in this way. public static String removeClone(String s, int idx, String str,boolean[] visited){ if(idx == s.length()) return str; int idx_v = s.charAt(idx) - 'a'; if(!visited[idx_v]){ str += s.charAt(idx); visited[idx_v] = true; } return removeClone(s, idx+1, str, visited); } public static void main(String[] args) { String s = "aabcadde"; boolean [] visited = new boolean[26]; System.out.println("Unique String: " + removeClone(s, 0, "", visited)); }
@harharmahadev1038
@harharmahadev1038 2 жыл бұрын
this will also work but i think it will increase your space complexity to O(n)
@harharmahadev1038
@harharmahadev1038 2 жыл бұрын
because you are using extra space
@AfridBasha-q5h
@AfridBasha-q5h 2 күн бұрын
for tower of hanoi while listening to half of the explanation i figured that it forms a series such that t(n+1)=2t{n) + 1 and t(1)=1. so on solving it you will get t(n)=2^n - 1; i know this video is about recursions but just mentioning it if someone try to find solution by series approach.
@sohanpulluru3049
@sohanpulluru3049 3 жыл бұрын
Great explaination!!!
@anshvashisht8519
@anshvashisht8519 2 жыл бұрын
1:13:30 please explain how the functions are called?
@raghavi.m-mj9gk
@raghavi.m-mj9gk Жыл бұрын
Did u get the answer for that,how two recursive calls will work
@rahuljain224
@rahuljain224 2 жыл бұрын
Thnx didi for this amazing lecture
@KashmiriBudShikan
@KashmiriBudShikan 11 ай бұрын
21:30 mam thought she is oversmart who faced the problem?
@sumit2306
@sumit2306 11 ай бұрын
yess broo, there's no logic for SMALLER DISKS ALWAYS ON THE TOP
@rajmaddheshiya4913
@rajmaddheshiya4913 2 ай бұрын
@@sumit2306 that is the demand of the question
@sandeepshah7840
@sandeepshah7840 Жыл бұрын
In the remove duplicate question if we use indexOf method of string the problem will much easier...😊
@biswajit07
@biswajit07 2 жыл бұрын
38:34 Please don't put the "else" here because if the element is occurring only once in the entire string, for example: if the string is "tabcdfghijakkkx" and we are searching for 'x', the output in this case (with the else) will be 14 and -1 but it should be 14 and 14 instead. So, we can basically just write last = idx without any if or else.
@KumarSahil78
@KumarSahil78 2 жыл бұрын
why it is happening ,can u explain bro
@dhrubajotidey6392
@dhrubajotidey6392 Жыл бұрын
for removing duplicate we can use string builder as well
@ThunDeRZeus07
@ThunDeRZeus07 10 ай бұрын
Is there a predefined function for that?
@unity3dtutorial976
@unity3dtutorial976 2 жыл бұрын
You explain in super way. Thanks a lot for the explaining this complex problem in very easy way.
@pritkumar9869
@pritkumar9869 Жыл бұрын
For unique subsequences, arrayList is enough as arrayList has contains method (hashSet wasn't required)
@ANKITKUMAR-vx2ej
@ANKITKUMAR-vx2ej Жыл бұрын
lots of love ❤... #best coder
@rajiv-59
@rajiv-59 2 жыл бұрын
mam great explaination of recursion ...................you didn't describe recursion so well in c++ placement course.......................
@CricketLive45-45
@CricketLive45-45 Жыл бұрын
54:47 That reaction when you are exited because you think your code is done and something goes wrong😂🤣
@sarthakgoyal2471
@sarthakgoyal2471 2 жыл бұрын
54:50--Didi's reaction 😂😂😂
@kishorchintalchere
@kishorchintalchere 3 жыл бұрын
Thanks a lot, keep making such videos 🙏🙏👌👌💯
@princekumarasstar7226
@princekumarasstar7226 3 жыл бұрын
I can't believe it...........never saw any teacher teaching programming feeling like NV SIR teach physics right now 😯✅😍
@shashwatsingh479
@shashwatsingh479 2 жыл бұрын
Can you provide me with the 1st part of this video plz.
@Jlol3hj
@Jlol3hj Жыл бұрын
​@@shashwatsingh479 of course
@mjmadmax
@mjmadmax 6 ай бұрын
if we consider a counter variable to count the steps . Then how to implement it, in the program??
@JAY_VEGAD
@JAY_VEGAD 9 ай бұрын
import java.util.Scanner; public class RecursionProblem3 { public static void FindChar(String str, int start, int end, String c) { if (start > end) { return; } if (str.charAt(start) == c.charAt(0)) { System.out.println("This is the index of a: " + start); } FindChar(str, start + 1, end, c); } public static void main(String[] args) { System.out.println("If Nothing is print so no char in your string"); Scanner sc = new Scanner(System.in); String s = "abanasaskandka"; int n = s.length(); System.out.print("Enter Char that you want to know: "); String c = sc.nextLine(); FindChar(s, 0, n - 1, c); sc.close(); } } in 3rd Q. This code is best and this is fast and take small amout of time and memory.
@Rieshu-s1m
@Rieshu-s1m 10 ай бұрын
#Apna College & Shradda didi rocks
@pranavgupta9673
@pranavgupta9673 3 жыл бұрын
God help those who help themselves.
@ultimatecreed5144
@ultimatecreed5144 3 жыл бұрын
Well said 👍
@gold_empire
@gold_empire 3 жыл бұрын
Plz make a videos on C for beginners in CSE
Recursion One Shot - Advanced Level Questions | Placement (Tech)
50:26
Recursion in One Shot | Theory + Question Practice + Code | Level 1 - Easy
1:25:04
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 62 МЛН
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН
GSoC 2025 Complete Roadmap | Google Summer of Code
18:30
Apna College
Рет қаралды 341 М.
Watch this before you start Coding! 5 Tips for Coders
13:53
Apna College
Рет қаралды 164 М.
DevOps Complete Guide for 2025
18:10
Apna College
Рет қаралды 142 М.
5 Mistakes Beginner Web Developers Make (Avoid These)
12:09
CodeWithHarry
Рет қаралды 114 М.
7 Indian Exam Tech You Didn't Know !
12:42
Tech Burner
Рет қаралды 982 М.
How I would learn to code (If I could start over)
13:14
CodeWithHarry
Рет қаралды 231 М.
Introduction to Recursion - Learn In The Best Way
1:55:49
Kunal Kushwaha
Рет қаралды 1 МЛН
50+ LPA Roadmap | ezSnippet | Neeraj Walia
17:02
Neeraj Walia
Рет қаралды 1,4 МЛН
How much HTML, CSS and JavaScript is Enough to get a Job 🔥
14:32
CodeWithHarry
Рет қаралды 388 М.