@@ -0,0 +1,1101 @@
+/**%0A * Given a circular array (the next element of the last element is the first element of the array), %0A * print the Next Greater Number for every element. The Next Greater Number of a number x is the %0A * first greater number to its traversing-order next in the array, which means you could search %0A * circularly to find its next greater number. If it doesn't exist, output -1 for this number.%0A */%0Apublic class Solution %7B%0A  public int%5B%5D nextGreaterElements(int%5B%5D nums) %7B%0A    int%5B%5D arr = new int%5Bnums.length%5D;%0A%0A    // Iterate through to find each greater element.%0A    for (int i = 0; i %3C arr.length; i ++) %7B%0A      int j = i + 1;%0A      int val = -1;%0A%0A      // For every element find the closest greater element from the front.%0A      while (j != i) %7B%0A        // For circular arrays.%0A        if (j %3E= arr.length) j = 0;%0A        // If a cycle has been completed then break.%0A        if (j == i) break;%0A        // The greater element has been found.%0A        if (nums%5Bj%5D %3E nums%5Bi%5D) %7B%0A          val = nums%5Bj%5D;%0A          break;%0A        %7D%0A%0A        j ++;%0A      %7D%0A      arr%5Bi%5D = val;%0A    %7D%0A%0A    return arr;%0A  %7D%0A%7D%0A

Add 503