title: Stream Operation of Two dimensional array
body: <p>I am trying to find the best average score from below two dimensional array:</p>
  
  <pre><code>String[][] scores = { { "Amit", "70" }, { "Arthit", "60" }, { "Peter", "60" }, { "Arthit", "100" } };
  </code></pre>
  
  <p><strong>The output is:</strong> 80 (Arthit's score (60+100)/2)</p>
  
  <p>Till now I solved this problem with below approach, however I am looking for elegant solution with stream:</p>
  
  <pre><code>public static void main(String[] args) {
          String[][] scores = { { "Amit", "70" }, { "Arthit", "60" }, { "Peter", "60" }, { "Arthit", "100" } };
  
          int highestAvg = Integer.MIN_VALUE;
          Function&lt;String[], Integer&gt; function = new Function&lt;String[], Integer&gt;() {
              @Override
              public Integer apply(String[] t) {
                  int sum = 0, count = 0;
                  for (int i = 0; i &lt; scores.length; i++) {
                      if (t[0].equals(scores[i][0])) {
                          count++;
                          sum += Integer.parseInt(scores[i][1]);
                      }
                  }
                  int avg = sum / count;
                  return highestAvg &lt; avg ? avg : highestAvg;
              }
          };
          System.out.println(Arrays.stream(scores).map(function).max((o1, o2) -&gt; o1.compareTo(o2)).get());
      }
  </code></pre>
  
  <p>Would you please suggest, what's the better approach to handle two dimensional array using stream?</p>
  
  <p>Note: <strong>I am not looking the exact solution, just looking your valuable suggestion.</strong></p>