title: Remove all Numbers that occur more than N times in the given Array
body: <p>I am working on the level 1 of the Google FooBar Minion scheduling challenge:</p>
  <blockquote>
  <p>Write a function called <code>solution(data, n)</code> that takes in a list of less
  than <code>100</code> integers and a number <code>n</code>, and returns that same list but with
  all of the numbers that <strong>occur more</strong> than <code>n</code> times <strong>removed</strong> entirely.</p>
  <p>The
  returned list should <strong>retain</strong> the same <strong>ordering</strong> as the original list -
  you don't want to mix up those carefully-planned shift rotations!</p>
  <p>For
  instance, if data was <code>[5, 10, 15, 10, 7]</code> and <code>n</code> was <code>1</code>, <code>solution(data, n)</code> would return the list <code>[5, 15, 7]</code> because <code>10</code> occurs twice, and thus
  was removed from the list entirely.</p>
  </blockquote>
  <p>This is my solution, but for some reason only 2 test cases are passing out of 10.</p>
  <p>The strange thing is, the open test case <code>{1, 2, 2, 3, 3, 3, 4, 5, 5}</code>, <code>n = 1</code> is also failing, while in my local IDE it passes.</p>
  <pre><code>public static int[] solution(int[] data, int n) {
      Map&lt;Integer, Integer&gt; map = new LinkedHashMap&lt;&gt;();
      
      if (data.length &lt; 1) {
          return data;
      }
      
      if (n &lt; 1) {
          return new int[0];
      }
      
      for (final int datum : data) {
          map.put(datum, map.getOrDefault(datum, 0) + 1);
      }
      
      List&lt;Integer&gt; t = map.entrySet()
          .stream()
          .filter(x -&gt; x.getValue() == 1)
          .map(Map.Entry::getKey)
          .toList();
      
      int[] b = new int[t.size()];
      
      for (int i = 0; i &lt; t.size(); i++) {
          b[i] = t.get(i);
      }
      
      return b;
  }
  </code></pre>