Frequency of Limited Range Array Elements | DSA | Programming Tutorials | GeeksforGeeks

Поділитися
Вставка
  • Опубліковано 20 жов 2020
  • Our courses :
    practice.geeksforgeeks.org/co...
    This video is contributed by Rahul Singla
    Please Like, Comment and Share the Video among your friends.
    Install our Android App:
    play.google.com/store/apps/de...
    If you wish, translate into the local language and help us reach millions of other geeks:
    ua-cam.com/users/timedtext_cs_p...
    Follow us on Facebook:
    / gfgvideos
    And Twitter:
    / gfgvideos
    Also, Subscribe if you haven't already! :)

КОМЕНТАРІ • 30

  • @lakshyamehta7529
    @lakshyamehta7529 3 роки тому +4

    GREAT EXPLAINATON!!
    Everyone is just repeating the written code but you explained that why we do all the steps.

  • @anshikaaa3716
    @anshikaaa3716 Рік тому +1

    I am commenting so that people should know that u have explained very well(every bit). And if someone doesn't get it then watch it again

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

    The best explaination I have seen so far ,thanks a lot for the last two efficient approaches , but in the last but one approach I got confused when you said e as arr[i]-e ,but it's actually arr[i]-1

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

    Extremely well explained. Thank you so much Sir. Keep it up!!!

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

    Awesome thinking
    In the starting i just got the frequency array concept
    The new one is really gud

  • @satwik_dash
    @satwik_dash 3 роки тому +1

    Last approach is the best, 2nd last does count to O(N) in Big-Oh, but we iterate more than N times so its not as good as the last one.

  • @princeshukla2761
    @princeshukla2761 9 місяців тому

    best explain sir and very very thanks from bottom of my heart

  • @Surya-np1bb
    @Surya-np1bb Рік тому

    Thanks for the explanation!

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

    Hi
    I have an array of positive integer {12,32,34,63,16,65,60}. My task is to count the occurence of each digit and return array with digits having max counts .
    Output
    arr2={1,2,3,6}.

  • @abhishekpattnaik8531
    @abhishekpattnaik8531 3 роки тому +1

    initial array is 2 3 2 3 5 then answer should be 0 2 2 0 1, but in 18:49 you say that its 0 2 1 0 1

  • @hamzaansari5714
    @hamzaansari5714 Рік тому +1

    The last method has some edge case issues

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

    23:01 best one 😊

  • @soumyadipsaha8904
    @soumyadipsaha8904 3 роки тому +1

    nice 👏👏

  • @saitama_capedbaldy9758
    @saitama_capedbaldy9758 3 роки тому +5

    Last approach is not good, it will not work in many cases

    • @piyush2947
      @piyush2947 3 роки тому

      Yes I am getting runtime error for last approach on some test case cases. But I don't know which one.

    • @piyush2947
      @piyush2947 3 роки тому

      I think it is because of int overflow

    • @PawanKumar-tu6ti
      @PawanKumar-tu6ti 2 роки тому

      you need to add few checks before you can paste the code. .. see some articles for greater insight

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

      @@piyush2947 is it fixed now ,
      same problem here as well
      tell me the solution if you got it.

  • @bravoboom3246
    @bravoboom3246 9 місяців тому

    TBH I spend more then hour to solve this problem and if you're beginner too then jump into second explanation that will be 23:05 and understand from there don't waste your time in first explanation because that is worst .

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

    JAVA SOLUTION IS HERE:
    class Solution{
    //Function to count the frequency of all elements from 1 to N in the array.
    public static void frequencyCount(int arr[], int N, int P)
    {
    // code here
    int i=0;
    while(iN){
    arr[i]=0;
    }
    if(arr[i]

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

    Can anyone tell why Signal Abort 3 error coming in my code
    void frequencyCount(vector& arr,int N, int P)
    {
    //SUBTRACT 1 FROME EACH ELEMENT SO THAT IT BECOMES INT THE RANGE 0 TO P-1
    for(int i=0;i

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

      i am also getting the same error , can't get where is error. Can anyone help ?

  • @ramakrishnabolisetty8550
    @ramakrishnabolisetty8550 3 роки тому +1

    (N) space not o(1) at

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

      he is modifying the same array so O(1) space

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

    The last algorithmic approach is giving runtime error;

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

      TRY THIS :
      class Solution{
      //Function to count the frequency of all elements from 1 to N in the array.
      public static void frequencyCount(int arr[], int N, int P)
      {
      int counti=0;
      for(int i=0;iN)
      {
      arr[i]=0;
      counti++;
      }
      else
      arr[i]--;
      }
      for(int i=0;i

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

    sorry but not pleased with the explanation(especially the last one)