Recursion in One Shot | 9 Best Problems

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ก.พ. 2025
  • Problems :
    00:05 - Tower of Hanoi
    26:40 - Print string in reverse
    32:06 - Find first & last occurrence of element
    41:11 - Check if the array is sorted (strictly increasing)
    48:59 - Move all 'x' to the end
    56:52 - Remove all duplicates in String
    01:05:50 - Print all subsequences
    01:21:31 - Print all unique subsequences
    01:26:28 - Print Keypad Combinations
    Codes in the Video : drive.google.c...
    Complete C++ Placement Course (Data Structures+Algorithm) : • C++ Full Course | C++...
    Telegram: t.me/apnikaksh...
    Instagram: / dhattarwalaman
    My TH-cam Gear 😉: docs.google.co...
    Notes of this Lecture:

ความคิดเห็น •

  • @prabhusingh7481
    @prabhusingh7481 3 ปีที่แล้ว +109

    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 2 หลายเดือนก่อน

      Placement kaisa rha fir???

    • @jayprakashkumar4492
      @jayprakashkumar4492 2 หลายเดือนก่อน

      😂😂😂​@@minaalkhajuria8681

  • @premnarain8077
    @premnarain8077 2 ปีที่แล้ว +7

    # 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.

  • @adityabhatt4177
    @adityabhatt4177 8 หลายเดือนก่อน +12

    looked 4 different videos then came here for the tower of hanoi problem and understood it in one go amazing...just amazing

    • @anwarbasha5073
      @anwarbasha5073 8 หลายเดือนก่อน +1

      if you understand can you explain me this one please

    • @abhijith7131
      @abhijith7131 7 หลายเดือนก่อน

      @@anwarbasha5073 watch the vedio of tap academy on tower of hanoi.They explained it very well graphically.

    • @nubguy8219
      @nubguy8219 3 หลายเดือนก่อน

      Same man really clear here

  • @theunknown5787
    @theunknown5787 ปีที่แล้ว +13

    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

  • @haritmishra3798
    @haritmishra3798 3 ปีที่แล้ว +7

    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 ปีที่แล้ว +7

    Such an interesting and easy method of teaching the hard topic with ease.Great !

  • @reshihashim4094
    @reshihashim4094 3 ปีที่แล้ว +20

    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 ❤️

  • @subhammishra316
    @subhammishra316 3 ปีที่แล้ว +18

    Thanx a lot , the lecture from c++ course was very difficult to cope up with👍👍😊

  • @AakshitaSingh
    @AakshitaSingh 11 หลายเดือนก่อน +8

    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;
    }

  • @avanish_shaw
    @avanish_shaw 8 หลายเดือนก่อน +9

    my mind suffered in pain after listing to the first explaination of tower of hanoi

  • @prabhu5220
    @prabhu5220 ปีที่แล้ว +18

    Can't thank you enough for this video , this video made me get less anxious about recursion . thank you so much!!

  • @vrgamerz12
    @vrgamerz12 2 ปีที่แล้ว +13

    Dii, you are so great teacher.. i saw java placement playlist and i understand java very well thank you very much.😇

  • @subhabratabasu9804
    @subhabratabasu9804 2 ปีที่แล้ว +4

    I am an it professional and still I watch your videos... They are helpful to relearning things

    • @digi_aayu
      @digi_aayu หลายเดือนก่อน +2

      You should not call urself a professional then😂

  • @stable577
    @stable577 ปีที่แล้ว +9

    33:06 (logic of initializing idx=-1 ), 47:46(array sorting code can be optimized)

  • @hari8568
    @hari8568 3 ปีที่แล้ว +17

    Really nice explanation of tower of Hanoi problem 👍👍

  • @arthurlewin1952
    @arthurlewin1952 3 ปีที่แล้ว +29

    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 ปีที่แล้ว +1

      yeah definately, i was really stucked at cpp playlist after recursion . But here it is.....

  • @guddubhaiya288
    @guddubhaiya288 3 ปีที่แล้ว +42

    Thank you Microsoft wali didi & also OP🙏🙏😊😊😊

  • @hustlewithnik
    @hustlewithnik 2 ปีที่แล้ว +30

    Thankyou for building logic and intution for such an difficult topic.VERY MUCH CLEAR AND ABLE TO SOLVE QUESTIONS ALSO.. You are amazing❤️❤️❤️

  • @Anonymous-qr5pz
    @Anonymous-qr5pz 2 ปีที่แล้ว +10

    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?

  • @prashantMishra-it2im
    @prashantMishra-it2im 3 ปีที่แล้ว +23

    This is the best way to explain which builds intuition and logic...thank u so much for your efforts 😇😇

    • @computer5548
      @computer5548 3 ปีที่แล้ว +1

      th-cam.com/video/tPaj5kF4l3I/w-d-xo.html

  • @spritualgamer5122
    @spritualgamer5122 ปีที่แล้ว +2

    The way of teaching is incredible 🎉

  • @vikastiwari8909
    @vikastiwari8909 หลายเดือนก่อน

    Such a good explanation ever seen this youth really need teacher like u🎉🎉🎉🎉

  • @ayushparikh9209
    @ayushparikh9209 3 ปีที่แล้ว +23

    Wow I didn't know it before that god "Brahma Ji" himself created tower of Hanoi algorithm ! 🙄 1:04

  • @nitishbagdiiiitu6779
    @nitishbagdiiiitu6779 ปีที่แล้ว +2

    Didi what an explaination !!! amazed
    but first question concepts is not mythology we are proud to be Hindu jai shree Ram

  • @swatimaheshwari9730
    @swatimaheshwari9730 2 ปีที่แล้ว +8

    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

  • @codexamofficial
    @codexamofficial 2 ปีที่แล้ว +18

    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 ปีที่แล้ว +3

      @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).

  • @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

  • @ShivamKumar-zj8bp
    @ShivamKumar-zj8bp 3 ปีที่แล้ว +416

    Didi please make a full course on android devlopment begeniers to advance with real life project 🔥🔥🔥

    • @sujeethgorati7062
      @sujeethgorati7062 3 ปีที่แล้ว +6

      Exactly bro.

    • @abhilashhadagali5572
      @abhilashhadagali5572 3 ปีที่แล้ว +3

      Haa really we need this

    • @MO-fg2cm
      @MO-fg2cm 3 ปีที่แล้ว +30

      Go find some other courses ... Don't wait for them to do ..

    • @Mohit-dk4jx
      @Mohit-dk4jx 3 ปีที่แล้ว +1

      Yes we need such courses

    • @ajay-iy4xb
      @ajay-iy4xb 3 ปีที่แล้ว +1

      I want also bro

  • @misbashaikh3357
    @misbashaikh3357 ปีที่แล้ว +6

    My fear for recursion all gone . thank you.i am literally enjoying it now 😊❤

  • @kasifmansuri7552
    @kasifmansuri7552 ปีที่แล้ว +4

    as alpha student this video still helps alot
    Thanks Shraddha mam

  • @sachinsoma5757
    @sachinsoma5757 2 ปีที่แล้ว +1

    This video helped me understand Tower of Hanoi clearly, thanks for the tutorial

  • @pankajsingh-cn3ec
    @pankajsingh-cn3ec 2 ปีที่แล้ว +1

    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.

  • @velocityvibezzz
    @velocityvibezzz ปีที่แล้ว

    Thanks so much. I learned so much about recursion through this and the previous video.

  • @TasniaSharin
    @TasniaSharin 2 หลายเดือนก่อน

    This video problem should be seen by those who are coding basic level. I just learn recursive

  • @pawangawale9053
    @pawangawale9053 9 หลายเดือนก่อน

    My Fav Question Was TowerOfHanoi, Find Occurance & Print Keypad Combination 😊

  • @subham5267
    @subham5267 3 หลายเดือนก่อน +1

    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));
    }
    }

  • @mansoorahmad5774
    @mansoorahmad5774 3 ปีที่แล้ว +5

    Best Recursive Explanation is at 56:55 "in the bottom right corner". xdxd

    • @computer5548
      @computer5548 3 ปีที่แล้ว

      th-cam.com/video/tPaj5kF4l3I/w-d-xo.html

  • @niteshsingh-ii5hx
    @niteshsingh-ii5hx 2 ปีที่แล้ว +5

    loved this video ! cleared all doubts on recursion.

    • @SONIC_6
      @SONIC_6 9 หลายเดือนก่อน

      ! Cleared or its cleared 😂

  • @supratiksarkar1195
    @supratiksarkar1195 2 ปีที่แล้ว +1

    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

  • @YUDDHYASWA
    @YUDDHYASWA 4 หลายเดือนก่อน

    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.

  • @CricketLive45-45
    @CricketLive45-45 ปีที่แล้ว

    54:47 That reaction when you are exited because you think your code is done and something goes wrong😂🤣

  • @randomvivek_
    @randomvivek_ 3 หลายเดือนก่อน +1

    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

  • @mdareefuddin2196
    @mdareefuddin2196 6 หลายเดือนก่อน

    Excellent teaching on recursion mam

  • @shifteditz06
    @shifteditz06 5 หลายเดือนก่อน +1

    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

  • @priyanshuvettori5179
    @priyanshuvettori5179 2 ปีที่แล้ว

    Yaar kitna achaa padhaati hai didi 😍

  • @rachitmathur1486
    @rachitmathur1486 3 ปีที่แล้ว

    Buckup Girl, you are the combined force of Goddess Parvati-Laxmi-Saraswati👍👍👍

  • @brajeshkumar462
    @brajeshkumar462 2 ปีที่แล้ว

    Thanku sister free me coding shikhane ke liye

  • @archanasoni9832
    @archanasoni9832 3 ปีที่แล้ว +2

    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

  • @hishrey
    @hishrey 7 หลายเดือนก่อน +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 6 หลายเดือนก่อน

      Can you explain me the dry run of keypad combination

  • @sudhanshuroy9673
    @sudhanshuroy9673 3 ปีที่แล้ว +9

    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 ปีที่แล้ว +2

      right

    • @PiyushAnand-td3fl
      @PiyushAnand-td3fl ปีที่แล้ว +1

      @@felix_72 i had the same doubt as she took array.length-1 in the next problem

  • @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 ^_^

  • @abhaykonge969
    @abhaykonge969 2 ปีที่แล้ว +1

    Didi is the best 😊 I means 'ek number' 👍

  • @sohanpulluru3049
    @sohanpulluru3049 3 ปีที่แล้ว +2

    Great explaination!!!

  • @khanfahad8289
    @khanfahad8289 3 ปีที่แล้ว +1

    Good teacher you all 👌👌👌

  • @sarthakgoyal2471
    @sarthakgoyal2471 3 ปีที่แล้ว +3

    54:50--Didi's reaction 😂😂😂

  • @shifteditz06
    @shifteditz06 5 หลายเดือนก่อน +1

    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

  • @shrutisah786
    @shrutisah786 ปีที่แล้ว +1

    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 6 หลายเดือนก่อน

      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

  • @VGS_7
    @VGS_7 3 ปีที่แล้ว

    what a blunder in notes of the tower of hanoi !

  • @SecretGameplays
    @SecretGameplays 2 ปีที่แล้ว +1

    At 20:00 didi ne to waqt badal diye, jazbbat badal diye, halat badal diye 🤣.....
    Didn't expect that.....🥲🥲🥲

    • @dheeraj7908
      @dheeraj7908 2 ปีที่แล้ว

      Exactly bro, output thik nhi aaye hat is code k?

    • @akashsahu5937
      @akashsahu5937 2 หลายเดือนก่อน +1

      @@dheeraj7908 wahi muje bhi lag rha hai

  • @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)

  • @striderar7813
    @striderar7813 3 ปีที่แล้ว +18

    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);
    }
    }

  • @Keeks_08
    @Keeks_08 ปีที่แล้ว

    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.

  • @dilipkumardhara1256
    @dilipkumardhara1256 หลายเดือนก่อน +1

    "Subsequences of a string" can be also called as "Subsets of a set", as per the set theory, we can calculate the time complexity by 2^(the cardinality of the set)
    Like A={a,b,c} then the number of all elements of the set A is 3, then all possible subsets of the set A will 2³=8.

  • @anubratadeb603
    @anubratadeb603 ปีที่แล้ว

    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

  • @shwetanksudhanshu4383
    @shwetanksudhanshu4383 2 ปีที่แล้ว +1

    Thanks very much for your efforts.🙂

  • @princekumarasstar7226
    @princekumarasstar7226 3 ปีที่แล้ว +5

    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

  • @ANKITKUMAR-vx2ej
    @ANKITKUMAR-vx2ej ปีที่แล้ว

    lots of love ❤... #best coder

  • @jaikumarm6964
    @jaikumarm6964 ปีที่แล้ว

    great video ,explanation is neat and understandable

  • @shanmugampoojan6412
    @shanmugampoojan6412 3 ปีที่แล้ว +3

    I love this channel....❤️

  • @smilemania5102
    @smilemania5102 3 ปีที่แล้ว +3

    this is called premium course

  • @kalpitbansal9923
    @kalpitbansal9923 6 หลายเดือนก่อน

    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

  • @smz3182
    @smz3182 6 หลายเดือนก่อน

    1:06:21 Subsequence of string

  • @guddubhaiya288
    @guddubhaiya288 3 ปีที่แล้ว +11

    Didi pls take live class for C++ programming pls didi😊😊😍😍😍

  • @mazharansari7813
    @mazharansari7813 3 ปีที่แล้ว +1

    54:45 that look though "ye code kaise work nahi hua?!??!!" 😂😂😁😁

  • @unity3dtutorial976
    @unity3dtutorial976 2 ปีที่แล้ว

    You explain in super way. Thanks a lot for the explaining this complex problem in very easy way.

  • @tysonelliot2591
    @tysonelliot2591 2 ปีที่แล้ว +11

    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

  • @amansayer4943
    @amansayer4943 2 ปีที่แล้ว +2

    how many got to know that tower of hanoi problem is different in lecture and notes provided by mam . by the way thank you mam for this much detail on tower of hanoi . the code in notes is incorrect instead of dest it is helper.

  • @AfridBasha-q5h
    @AfridBasha-q5h หลายเดือนก่อน

    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.

  • @mirzamohammadabbas2221
    @mirzamohammadabbas2221 3 ปีที่แล้ว +4

    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

  • @rajiv-59
    @rajiv-59 2 ปีที่แล้ว +2

    mam great explaination of recursion ...................you didn't describe recursion so well in c++ placement course.......................

  • @copilotcoder
    @copilotcoder 2 ปีที่แล้ว

    Awesome teacher plzz use this potential of urs..... it feels so bad by seeing this channel is doing nothing....where others are taking the first mover advantage

  • @devangseksaria4888
    @devangseksaria4888 2 ปีที่แล้ว +3

    45:54 why are putting return after calling the isSorted function again??

  • @kunalkushwaha5835
    @kunalkushwaha5835 3 ปีที่แล้ว +5

    ty mam u r awesome

  • @bhupendradixit3308
    @bhupendradixit3308 2 ปีที่แล้ว +4

    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.

  • @ssk7690
    @ssk7690 2 ปีที่แล้ว +1

    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 11 หลายเดือนก่อน

      if(first== -1) {
      first = index;
      }
      last = index;
      else is not required only.

  • @sameersahto
    @sameersahto 2 ปีที่แล้ว +1

    REcursion is hard to learn it messes with your mind on whole other level

  • @rahuljain224
    @rahuljain224 2 ปีที่แล้ว +1

    Thnx didi for this amazing lecture

  • @gold_empire
    @gold_empire 3 ปีที่แล้ว +5

    Plz make a videos on C for beginners in CSE

  • @sandeepshah7840
    @sandeepshah7840 ปีที่แล้ว

    In the remove duplicate question if we use indexOf method of string the problem will much easier...😊

  • @KashmiriBudShikan
    @KashmiriBudShikan ปีที่แล้ว +2

    21:30 mam thought she is oversmart
    who faced the problem?

    • @sumit2306
      @sumit2306 ปีที่แล้ว

      yess broo, there's no logic for SMALLER DISKS ALWAYS ON THE TOP

    • @rajmaddheshiya4913
      @rajmaddheshiya4913 4 หลายเดือนก่อน

      @@sumit2306 that is the demand of the question

  • @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

  • @momentwithujjwal2850
    @momentwithujjwal2850 3 ปีที่แล้ว

    Sach me maja aa gya... !!!

  • @pritkumar9869
    @pritkumar9869 ปีที่แล้ว +4

    For unique subsequences, arrayList is enough as arrayList has contains method (hashSet wasn't required)

  • @balasagargoud326
    @balasagargoud326 2 ปีที่แล้ว +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

  • @premverma8220
    @premverma8220 2 ปีที่แล้ว

    In question first and last occurence it is failing for the input abbbccc for element a the correct code will be:
    public static void findOccurence(String s,int idx,char element)
    {
    if(idx==s.length())
    {
    System.out.println(first);
    System.out.println(last);
    return;
    }
    if(s.charAt(idx)==element)
    {
    if(first==-1){
    first=idx;
    last=idx;
    }
    else
    last=idx;
    }
    findOccurence(s,idx+1,element);
    }

  • @dhrubajotidey6392
    @dhrubajotidey6392 2 ปีที่แล้ว +3

    for removing duplicate we can use string builder as well

    • @ThunDeRZeus07
      @ThunDeRZeus07 ปีที่แล้ว

      Is there a predefined function for that?

  • @lost2932
    @lost2932 11 หลายเดือนก่อน +1

    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 6 หลายเดือนก่อน

      Still the time complexity would be the same i think

    • @Rex-j1q
      @Rex-j1q 4 หลายเดือนก่อน

      @@kamaleshwaran5802 but still better than using for loop

  • @JAY_VEGAD
    @JAY_VEGAD 11 หลายเดือนก่อน +1

    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.

  • @CodeAxisJourney
    @CodeAxisJourney ปีที่แล้ว

    Thank you so much for your efforts ❤

  • @ranvijaypatel3213
    @ranvijaypatel3213 9 หลายเดือนก่อน +2

    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);
    }