Ep5 - Using recursion, check whether a string is a palindrome or not | DSA series

Поділитися
Вставка
  • Опубліковано 24 сер 2024
  • To check whether a string is palindrome or not is very easy. You can do this question with the help of the FOR loop, but in this video, we will learn how to do this with the help of recursion. Now you might ask, why are we doing this when we already know one method? These basic questions will help you build up your strong base for the harder problems. So don't skip these videos and share them with your friends too.
    Practice - bit.ly/39UrBjK
    Code available in Cpp, Java, Python - github.com/Lea...
    Main channel link - bit.ly/3GBAV7f
    DSA Placement series - • DSA Placement series
    Recursion playlist - • Recursion
    🔴Watch the complete Linked List Series • Linked List Series
    To get all updates follow on Instagram
    / frazmohammad
    👨‍💻Utilize free courses, DSA sheet, and articles on Lead Coding website at
    Join our telegram channel for all the important announcements
    t.me/leadcoding
    ✨ Hashtags ✨
    #DSA #Recursion #Placement #Fraz

КОМЕНТАРІ • 194

  • @iamdhirajshastri
    @iamdhirajshastri 2 роки тому +48

    Day 5 Done ✅
    Congratulations Guys, if you are consistent from last 5 days because 5th & 10th day are the most difficult day of consistency ⚡ By the time you'll reach 21st day you will be champ. 👑 Hope this motivates you all❤😊

  • @AbhishekVerma-ev5tv
    @AbhishekVerma-ev5tv 2 роки тому +6

    Points -
    1. Basic solution is to use two pointers from middle, from ends OR reverse the string.
    2. In recursion, we will only take the loop and convert it to recursion. i.e. we still will have left and right end chars in same call (and not have some mechanism to store and compare in appropriate number of call). L and R represent the substring which needs to be checked for substring. [hence the 0 and n-1 initial values as we need to check whole string at first.]
    3. Since, we return boolean as final answer, we will return true/false in base and invalid cases (here base case is a valid case). For Induction step(where we make next call), we don't need to take and/or since this is a Unary recursion tree.
    *Note - Recursive solution is "inferior" to iterative solution in terms of space complexity (expected due to stack)

  • @productivewind
    @productivewind 2 роки тому +7

    Sorry for the late Fraz bhaiya. But EP 5 is DONE. Thank you for your consistency and I always appreciate you for your 0 to pro
    type content.

  • @gouravmehra007
    @gouravmehra007 2 роки тому +4

    I have solving palindrome problems using loop, today i learnt new thing that we can solve it using recursions as well. thanks bro.

  • @naveenh183
    @naveenh183 2 роки тому +7

    One small suggestion Fraz bhai ..!! The logic explanation is superb.! In one go I am able to understand. It would be good if you can explain the code also so that it will be easy for us to understand and this helps us to explain to interviewer also in much smoother way. Because these days interviewers are preferring the explanation of code which we write. I know it might look silly suggestion but it helps us a lot.

  • @nihalbarudwale
    @nihalbarudwale 2 роки тому +13

    Can you share 1 problem as a homework like after discussing 1 problem in video, you can give us that topic related problem for solving.
    I understood the recursion concept well thanks to you.

  • @anirudrabrahma_0971
    @anirudrabrahma_0971 2 роки тому +14

    I always do the problem using iterative solution 😂 learnt the recursion approach from this video. Thank you so much for hard work and regularity. Keep on doing that, enjoying so much big bro ❤️❤️

    • @LearnYardYT
      @LearnYardYT  2 роки тому +6

      Woow I see your comment daily ❤️.
      Thanks for writing ☺️

    • @anirudrabrahma_0971
      @anirudrabrahma_0971 2 роки тому +3

      @@LearnYardYT Yeah i love these videos so much because I badly waiting for such bootcamp which covers everything and not wasting time much. I know how you work hard for us. So it is a greatfulness towards you. ❤️

    • @ramakrishna4092
      @ramakrishna4092 2 роки тому +1

      @@LearnYardYT l==r right for base condition why L>=r

    • @ramakrishna4092
      @ramakrishna4092 2 роки тому +1

      @@LearnYardYT can you pls tell me why L>=R in the base condition L== R what is the difference in that

    • @ritikchauhan8902
      @ritikchauhan8902 2 роки тому +2

      @@ramakrishna4092 it helps when size of string is even , do dry run of {1 2 1 1 2 1},you will understand

  • @bhupendrasingh7788
    @bhupendrasingh7788 2 роки тому +2

    You are hard working for us until finish this series I will never give up
    I will watch your daily lectures and be consistent

  • @sriramulavenkatakrishnakar3724
    @sriramulavenkatakrishnakar3724 2 роки тому

    take a bow for ur consistency

  • @Shorts-sc3is
    @Shorts-sc3is 2 роки тому +3

    Provide assignments for practice daily. This will help everyone.

  • @piyushsrivastava5581
    @piyushsrivastava5581 2 роки тому +2

    A small request Fraz to cover more in one video and also plz dry run the code for a few cases. Gives loads of insight like in last video you did ♥️♥️!!! #missionamazon

  • @saha7pritam
    @saha7pritam 2 роки тому

    Yeah, now catch your speed.. Feeling confident. 👍

  • @krishnakakade3081
    @krishnakakade3081 2 роки тому

    The way of explaination is mindblowing. Keep it up.

  • @mayurpowar2460
    @mayurpowar2460 2 роки тому

    Palindrome problem is now bit easier 🔥🔥

  • @curiouspatel
    @curiouspatel 2 роки тому +1

    Ep5 also done successfully ✅
    Abhi tk sbkuchh mst samajh aa ra 😌

  • @vaishnavirathore5579
    @vaishnavirathore5579 Рік тому

    bhai bht acha kaam kra h ....lots of love :)

  • @aakashbhargava1
    @aakashbhargava1 2 роки тому +2

    I think we should increase pace of this course its just a suggestion and you know better than me fraz bhaiya
    thank you

  • @souvikmukherjee8419
    @souvikmukherjee8419 2 роки тому

    With this course, you are giving us more than DSA lessons
    You are teaching us discipline perseverance and to show up every day no matter what(which will stay for life)
    Thank you so much bhaiya♥

  • @ismitsingh7349
    @ismitsingh7349 2 роки тому +3

    Bhaiya lectures are really good. Like as a beginner I am understanding this recursion series very well but pls suggest how to gain confidence over topic of time and space complexity

  • @apptrendz
    @apptrendz 2 роки тому +14

    JAVA CODE
    public class Solution {
    public static void main(String []args){
    Solution ans= new Solution();
    String obj="level";
    ans.isPalindrome(obj);
    }
    public static Boolean Palindrome(int i, int j,String s) {
    if(i>=j) return true;
    if(s.charAt(i)!=s.charAt(j)) return false;
    return Palindrome(i+1,j-1,s);
    }
    public static Boolean isPalindrome(String s) {
    System.out.println(Palindrome(0,s.length()-1,s));
    return Palindrome(0,s.length()-1,s);
    }
    }

    • @amansayer4943
      @amansayer4943 Рік тому

      iss it necessary tom take the helper functions

  • @snehadas2062
    @snehadas2062 Рік тому

    Waiting for next topics!

  • @amarnathbarpanda5884
    @amarnathbarpanda5884 2 роки тому

    the simplest explanation ever.. loved it.

  • @anuragkaushik739
    @anuragkaushik739 2 роки тому +1

    Concept cleared !!!amazing

  • @Abhishek-fo3fc
    @Abhishek-fo3fc 2 роки тому +1

    Done understood day 5✅

  • @saisravani2625
    @saisravani2625 2 роки тому

    watched till end 👍

  • @zeeshanansari2232
    @zeeshanansari2232 2 роки тому

    Thnq bhaiya for ur every effort

  • @surakshitkapoor9373
    @surakshitkapoor9373 2 роки тому

    superb video
    having no doubt😊

  • @mohitroshan3856
    @mohitroshan3856 2 роки тому

    Eagerly waiting for the video daily same as i used to wait for a show on TV in my childhood😄😁

  • @ratnasanjay
    @ratnasanjay 2 роки тому

    Thankyou bhaiya for this session

  • @nithins3895
    @nithins3895 2 роки тому

    Thanks for the video
    Day 5
    Consistency✌✌✌

  • @raiyankhan2367
    @raiyankhan2367 2 роки тому

    very good series

  • @avadhutlohar5181
    @avadhutlohar5181 2 роки тому +2

    #DAY_5
    Consistency OP🔥🔥🔥🔥

  • @dipeshjoshi9126
    @dipeshjoshi9126 2 роки тому

    video best like previous.n/2 is write because there is 0 to 4 and all i assumen .baki no doubts.ur videos is like 6 baj gaya aaaj ka video chalo kar lete hai .im student .but ik working professional ke liye ye daily challange time ki waje se kaffi accha lag raha hoga superb bhaiya.consistent op

  • @dashundev1586
    @dashundev1586 2 роки тому

    Very clear

  • @darshankalathiya8667
    @darshankalathiya8667 2 роки тому

    you are one of the best teacher keep uploading videos brother...

  • @amitranjeetjha1240
    @amitranjeetjha1240 2 роки тому

    Fraz bhai 🔥🔥

  • @prantikofficial
    @prantikofficial 2 роки тому

    Great video !

  • @spacelovertelugu44spacelov46

    So ideally , out depends on inner output is varied in this recurssion

  • @TravelTracksByDebo
    @TravelTracksByDebo 2 роки тому

    wonderful video

  • @raghu8401
    @raghu8401 2 роки тому

    so great brother

  • @ajayprajapati3029
    @ajayprajapati3029 11 місяців тому

    this is very expensive seriese
    🥰🥰🥰

  • @ramankr0022
    @ramankr0022 Рік тому

    very helpful

  • @faisalehsan7407
    @faisalehsan7407 2 роки тому

    Very well explained ! ..Thanks for your support

  • @mma-dost
    @mma-dost 6 місяців тому

    Thanks bhaiya

  • @hiiiiiiii927
    @hiiiiiiii927 2 роки тому

    Day 5 completed
    Please give more questions for practice and homework

  • @shalimar_mehra
    @shalimar_mehra 2 роки тому

    Present ! I'm owner to you for this lovely video ! Please make more video on recursion ! It Will help me more to strong my DSA Knowledge !🙌✔

  • @ankittjindal
    @ankittjindal 2 роки тому

    oosm explanation

  • @manikgoel9953
    @manikgoel9953 2 роки тому

    Thanks

  • @akashreddyallam8536
    @akashreddyallam8536 2 роки тому

    Thanks!

  • @sanketbhagat1222
    @sanketbhagat1222 2 роки тому +3

    bhaiya, can you please share the syllabys plan for your course? means expected dates for completion of topics.

  • @Sahilsharma-sk5vr
    @Sahilsharma-sk5vr Рік тому

    thank you sir

  • @rajankhunt7002
    @rajankhunt7002 2 роки тому

    Good Video

  • @abhishekpandey8988
    @abhishekpandey8988 2 роки тому

    Nice explanation bhaiya.
    Thank you for this video

  • @avishekdastidar7646
    @avishekdastidar7646 2 роки тому

    solved this problem using recursion for the first time...

  • @VinayakH
    @VinayakH 2 роки тому +1

    Class 5 done☑

  • @budhadityachatterjee6270
    @budhadityachatterjee6270 2 роки тому

    Ep: 5 Done !

  • @aakashbhargava1
    @aakashbhargava1 2 роки тому

    waiting for more such content!!!

  • @chandrashekharsahu9639
    @chandrashekharsahu9639 2 роки тому

    THANKS

  • @divyanshsagar
    @divyanshsagar 2 роки тому

    Nicely explained!

  • @Gauravkumar-kc6xh
    @Gauravkumar-kc6xh 2 роки тому

    Great

  • @arupsarkar6871
    @arupsarkar6871 2 роки тому

    It is very good

  • @maazulhaque7293
    @maazulhaque7293 2 роки тому

    Lec 5 Done

  • @Sahilsharma-sk5vr
    @Sahilsharma-sk5vr Рік тому

    thanks

  • @oqant0424
    @oqant0424 2 роки тому

    Episode 5 done ✅

  • @autodocofficial2161
    @autodocofficial2161 2 роки тому

    done bhaiya..completed

  • @adarshsingh4693
    @adarshsingh4693 2 роки тому +1

    day 5 done

  • @vinaykamble162
    @vinaykamble162 2 роки тому +1

    Complete Day 5 ❤️

  • @aveermukherjee6419
    @aveermukherjee6419 2 роки тому

    nice explanation keep up the good work.

  • @Sandeep-zd6dq
    @Sandeep-zd6dq 2 роки тому

    Bhaiya we want more questions🔥🔥 great explaination

  • @mdsufyankhan1029
    @mdsufyankhan1029 2 роки тому

    Sorry for the late bhaiya 🥲
    But covering all your videos
    Keep making , its very effective ❤️

  • @babushaikh6582
    @babushaikh6582 2 роки тому

    I like yours video's 🥰

  • @SRV.77
    @SRV.77 2 роки тому

    😊😊😊Thank u bhaiya

  • @DeepakTiwari-bb9tm
    @DeepakTiwari-bb9tm 2 роки тому

    Now revision 💪

  • @mdiqbalhayat5420
    @mdiqbalhayat5420 Рік тому

    class PalindromClass{
    public static void main(String args[]) {
    String input = "racecar";
    boolean result = PalindromClass.Palindrom(0, input.length()-1, input);
    System.out.println(result);
    }
    public static boolean Palindrom(int l, int r, String s) {
    if(l>=r) return true;
    if(s.charAt(l) != s.charAt(r)) return false;
    return Palindrom(l+1, r-1, s);
    }
    }

  • @papiananda5547
    @papiananda5547 2 роки тому

    Thank you for so good digestible content. One request can you come up with a small scenario of real time project where we are using these DSA concepts. As of filling a form where next questions are based on previous one and have a concept of DSA. Thank you in advance...

  • @ajourneyforfun1979
    @ajourneyforfun1979 2 роки тому

    Forgot to comment, now done😁

  • @kapiltanwer552
    @kapiltanwer552 6 місяців тому

    nice video

  • @sagarpokhriyal6926
    @sagarpokhriyal6926 2 роки тому +1

    Lecture 5 - ☑
    #Dsabyfaraz
    #recursion❤

  • @261_vijayrajsolanki4
    @261_vijayrajsolanki4 2 роки тому

    Good

  • @prakharagarwal4933
    @prakharagarwal4933 2 роки тому +1

    Done✅

  • @surakshitkapoor9373
    @surakshitkapoor9373 2 роки тому

    great lecture😊

  • @ranitbandyopadhyay
    @ranitbandyopadhyay 2 роки тому

    Video is good with the analysis.

  • @chandanchoudhary349
    @chandanchoudhary349 2 роки тому

    hw done bhaiya

  • @healerbigboss1812
    @healerbigboss1812 2 роки тому

    there is another approach that i used for solving this question hope it can help someone
    bool pallindrom(int index,int size, string &s)
    {
    if(index>=size/2)
    return true;
    if(s[index]!=s[size-index-1])
    return false;
    pallindrom(index+1,size,s);
    }
    bool isPalindrome(string &s)
    {
    return pallindrom(0,s.size(),s);
    }

  • @palaksinghal5722
    @palaksinghal5722 2 роки тому

    Day 5 Done🙂

  • @jugalshah8199
    @jugalshah8199 2 роки тому

    We can do it this way as well without making two diff functions.
    bool isPalindrome(std::string str, int s = -1, int e = -1){
    if(s==-1 && e==-1){
    s = 0; e = str.size() - 1;
    }else if (s > e){
    return true;
    }
    if(str[s] == str[e]) return isPalindrome(str, ++s, --e);
    return false;
    }
    int main(){
    // TODO: Testcase
    // Start Each Test Case from here.
    std::string s; std::cin >> s;
    std::cout

  • @satyammishra6356
    @satyammishra6356 2 роки тому

    Day 5
    Done✅✅

  • @kundanrajpoot212
    @kundanrajpoot212 2 роки тому +1

    Sir, please cover data structures like vectors, maps stacks, queues etc in details.
    Please sir it will be very helpful for people like me who are absolute beginner .

    • @kundanrajpoot212
      @kundanrajpoot212 2 роки тому +1

      Please all these data structures just after this recursion sessions !!

  • @amanbhojak8281
    @amanbhojak8281 2 роки тому

    enjoying

  • @AyushKumar-gf5th
    @AyushKumar-gf5th 2 роки тому

    Ep5 DONE.

  • @yashbahuguna8135
    @yashbahuguna8135 2 роки тому

    #day 5 -done

  • @praash.
    @praash. 2 роки тому

    Very useful video because since 5 days I solve this question but this solution is best .
    Bhaiya can you make a video for iteratively Approach please.

  • @akhileshwarpandit5632
    @akhileshwarpandit5632 2 роки тому

    completed👍

  • @PROTECHRAHUL
    @PROTECHRAHUL 2 роки тому

    Please take more examples or questions on logarithmic time complexity. N also tell please bhaiyaa how to find or think when we can say this is taking log time/space

  • @rogdex24
    @rogdex24 2 роки тому

    Edit the video to zoom on the code you are writing , it will be more comfortable and good for viewing

  • @emtiazahmed5333
    @emtiazahmed5333 2 роки тому

    I was check this channel at 6pm but kuch nahi tha🤕 when you upload this lecture☹️

  • @boom_smash
    @boom_smash 2 роки тому

    Day 5 completed

  • @dewanshanand1395
    @dewanshanand1395 2 роки тому

    8th june - done (Started Late)

  • @surabhichoubey2987
    @surabhichoubey2987 2 роки тому

    Thank you soo much bhiya for your efforts 🙌 present

  • @DTMASUYASHMISHRA
    @DTMASUYASHMISHRA 2 роки тому

    Sir give some other practice problems for hw