title: Terminated due to timeout for my hacker rank solution
body: <p>Hello all please check the problem<a href="https://www.hackerrank.com/challenges/migratory-birds/problem" rel="nofollow noreferrer">HackerRank Problem Statement</a></p>
  
  <p>This is my solution for the above problem(link) </p>
  
  <pre><code>static int migratoryBirds(List&lt;Integer&gt; arr) {
      int ar[]=new int[arr.size()];
      for(int i=0;i&lt;arr.size();i++){
          ar[i] = Collections.frequency(arr,arr.get(i));
          // ar[i] = obj.occuranceOfElement(arr,arr.get(i));
      }
      int maxAt = 0;
      for (int i = 0; i &lt; ar.length; i++) {
          maxAt = ar[i] &gt; ar[maxAt] ? i : maxAt;
      }
      return arr.get(maxAt);
  }
  </code></pre>
  
  <p><strong>my code is unable to handle when the array size is bigger,example 17623 elements in array</strong>.</p>
  
  <blockquote>
    <p>Terminated due to timeout</p>
  </blockquote>
  
  <p>The problem is in the second for loop which iterates over the array and gives me the index of the largest number in the array.<strong>Is there any other way that I could increase the performance.</strong></p>