We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Implementation
  4. Migratory Birds
  5. Discussions

Migratory Birds

Problem
Submissions
Leaderboard
Discussions
Editorial

    You are viewing a single comment's thread. Return to all comments →

  • mohamedhossamah1
    2 months ago+ 0 comments

    c with frequancy array

     
    
     int frequancyarray2(int arr_count, int* arr){
         int max= 0 , maxvalue ; 
          int * data = (int*)calloc(6 , sizeof(int));
          for(int i = 0 ; i <= 5; i ++){
              data[i]=0 ;
          }
          for (int i = 0 ; i < arr_count ; i ++){
              data[arr[i]] ++ ; 
          }
          max = data[0];
          maxvalue= 0 ;
          for (int i = 1 ; i <= 5 ; i ++){
             if (data[i] > max){
                 max = data[i] ;
                 maxvalue = i ;
             } 
          }
          free (data);
       return maxvalue;   
     }
    
    1|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy