/**
 * @Company Google
 *
 * Given an array of length n and an integer k where 0 < k <= n, find the largest subarray of length k by the following definition.
 * Subarray A is larger than subarray B if the value at index i is greater. Similar to the lexicographical ordering of strings.
 * The first occurence of a value that differs between A and B will determine which ever is bigger.
 * 
 * Ex. [ 1, 2, 2, 2, 4 ] is larger than [ 1, 2, 2, 2, 3 ]
 *     [ 1, 4 ] is larger than [ 1, 2 ]
 *
 * Problem Ex.
 *   Input: [ 1, 4, 1, 4, 5 ], k = 3
 *   Output: [ 4, 1, 4 ]
 *
 *   There are 3 subarrays of length 3 in the given array, [ 1, 4, 1 ], [ 4, 1, 4 ], [ 1, 4, 5 ].
 *   The ordering of the three subarrays from greatest to least are as follows:
 *   [ 4, 1, 4 ]
 *   [ 1, 4, 5 ]
 *   [ 1, 4, 1 ]
 * 
 *   [ 4, 1, 4 ] is the largest because its first index is already greater than the other two subarrays.
 *   Since we want the greatest subarray, the answer will be the first one.
 *   The order of the next two are determined at index 2 because 5 > 1.
 *
 * Note: there are n - k + 1 subarrays in an array of length n of size k.
 */
public int[] largestSubarray(int[] arr, int k) { }


@@ -1138,16 +1138,23 @@
 %0Apublic 
+static 
 int%5B%5D la
@@ -1190,8 +1190,766 @@
 k) %7B
- %7D%0A%0A
+%0A  int numOfSub = arr.length - k + 1;%0A  int%5B%5D%5B%5D subarrays = new int%5BnumOfSub%5D%5Bk%5D;%0A  int maxIndex = 0;%0A%0A  for (int i = 0; i %3C numOfSub; i ++) %7B%0A    boolean updated = false;%0A    for (int j = 0; j %3C k; j ++) %7B%0A      subarrays%5Bi%5D%5Bj%5D = arr%5Bi + j%5D;%0A%0A      // If the current subarray is the max subarray, then just populate.%0A      // Also, if the max subarray has already been updated then, just populate.%0A      // Also, continue if the two values are equal.%0A      if (i == maxIndex %7C%7C updated %7C%7C subarrays%5Bi%5D%5Bj%5D == subarrays%5BmaxIndex%5D%5Bj%5D) continue;%0A%0A      // New max sub array%0A      if (subarrays%5Bi%5D%5Bj%5D %3E subarrays%5BmaxIndex%5D%5Bj%5D) maxIndex = i;%0A%0A      // Set update to true regardless of which is greater.%0A      updated = true;%0A    %7D%0A  %7D%0A%0A  return subarrays%5BmaxIndex%5D;%0A%7D

Add largest subarray solution