import java.util.Arrays;
public class VMwareOA {
public static int[] maxNumIndex(int[] rotate, int[] nums) {
if (nums == null || rotate == null || nums.length < 1 || rotate.length < 1) return new int[0];
int maxNum = nums[0], maxIdx = 0;
int n = rotate.length; // the length of rotate array
int m = nums.length;
int[] res = new int[n];
for (int i = 1; i < nums.length; i++) {
if (nums[i] > maxNum) {
maxNum = nums[i];
maxIdx = i;
}
}
for (int i = 0; i < n; i++) {
res[i] = ((maxIdx + m) - rotate[i]) % m;
}
return res;
}
public static void main(String[] args) {
// Testcase1: [0,1,2,3,4,5,6,7,8,9] [1,4,3,2,7,3]
int[] res1 = maxNumIndex(new int[] {0,1,2,3,4,5,6,7,8,9}, new int[] {1,4,3,2,7,3});
System.out.println(Arrays.toString(res1));
// Testcase2: [0,-1,-2,-3,-4,-5,-6,-7,-8,-9] [1,2,3,4,5]
int[] res2 = maxNumIndex(new int[] {0,-1,-2,-3,-4,-5,-6,-7,-8,-9}, new int[] {1,2,3,4,5});
System.out.println(Arrays.toString(res2));
}
}