1. Anagrams | Strings | Multiple methods with Optimisations & Code! New Series! ❤️🚀💪

Поділитися
Вставка
  • Опубліковано 18 жов 2024

КОМЕНТАРІ • 40

  • @codefromscratch-keertipurswani
    @codefromscratch-keertipurswani  2 роки тому +3

    Guys! Whenever your map or vector will have constant size (like in this question - 26 chars), your space complexity will be O(1). Should have explained this more. Will take it up in future quess! ❤️

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

      Mam plz explain the stl in string or bring up a vedio only based on string stl plz it will be reay helpfull.

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

    The video was very helpful. Pls continue with more String questions! Thank you so much di.
    Tried one more method with o(n) time and o(1) space complexity.
    int a_len=a.length(),b_len=b.length();
    if(a_len!=b_len) return false;
    StringBuilder str_a = new StringBuilder(a);
    StringBuilder str_b = new StringBuilder(b);
    char ch;
    int index;
    for(int i=0;i

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

    Thank you for the string series and keep it up 👍❤

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

    Thanks di for starting the String Series....Please cover all types and all level of questions on string: EASY TO HARD (Till dp) ...Pleaseeeee

  • @ShubhamSingh-gk8vp
    @ShubhamSingh-gk8vp 2 роки тому +1

    was eagerly waiting for video!! thankyou!!

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

    Present.. Well explained!!

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

    array might be good choice as we will not change length of the counter. Great video!

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

    Already knew the approaches yet wanted to revise again thanks for posting

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

    Thanks for the new series

  • @Nishchay-kc1gb
    @Nishchay-kc1gb 2 роки тому

    I am really bad at strings and looking forward for this series to make my problem solving skills in strings more strong

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

    Spot on 👍

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

    Good to see you back. Please be consistent. It motivates us to be consistent

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

    Present. thanks for clear explanation

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

    My morning starts with ...watching and practicing this question , again a fab one mam !!

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

    In the first solution where you are comparing string will the time complexity be (nlogn+n) n for relational operation comparison of 2 string?

    • @codefromscratch-keertipurswani
      @codefromscratch-keertipurswani  2 роки тому +1

      Yup you are right. But since nlogn is more than n, I just mentioned nlogn. Will be more descriptive next time! Thank you! ❤️

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

    Present ✌👍 your explained very well 👌🏻

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

    I would like to tell you please use little bit hindi in between so all the students can easily able to understand the solution in an easy way .your way of explanation is really awesome

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

    Can the solution/tutorial be in java?

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

    Thank you di...🚀💥

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

    present mam!!

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

    Thank you :)

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

    🙋.. one doubt, how the using map sol sc in O(N)? In the map the key always should be in range between 1 to 26 ryt.. so the key can be maximum 26 always. So cant we consider this as O(1)?

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

    Didi XOR s bhi ho jata h yeah...

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

    Present. Tried all the above methods. In addition, i could do one more method, with o(1) space and O(a+b) time complexity
    Could get all GFG testcases passed for this solution:
    public static boolean isAnagram(String a,String b)
    {
    int sum=0;
    for(Character charctr : a.toCharArray()){
    sum = sum+charctr;
    }// end of for loop on first word

    for(Character charctr : b.toCharArray()){
    sum = sum-charctr;
    }// end of for loop on second word
    if(sum == 0){
    return true;
    }
    return false;
    }
    UPDATE: This method will not work because of reasons cited below.

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

      I think it should not work...correct me if I am wrong...
      Test case on which it should fail is as below :
      String 1 : az
      String 2 : by
      As a+z == b+y in int format, your code will consider this as an anagram

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

      @@ketanlalcheta4558 Thanks a lot for the insight. Gfg test cases mit not be testing this case.

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

      @@arunkumarmohandas4420 yeah seems so... but great to try different implementation... good effort and makes us think more...

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

    Present 🙂

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

    Present 👍

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

    Present

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

    Didi apki vdosm view nhi aare hai.....apko kuch changes krne chaiye...

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

    Present