As reported: IBM online assessment on HackerRank (2025), two questions: the first returned the sum of an array; the second, below, asked for the first larger element's index in another array.
You are given two integer arrays arr1 and arr2. For each element x of arr1, find the smallest index j such that arr2[j] > x. If no element of arr2 is greater than x, the answer for x is -1. Return the answers in the order of arr1.
Example
arr1 = [3,1,5,6]
arr2 = [4,1,5,6]
-> [0,0,3,-1]
3: arr2[0] = 4 > 3 → 0. 1: 4 > 1 → 0. 5: indices 0–2 hold 4,1,5, none greater; arr2[3] = 6 → 3. 6: nothing is greater → −1.
Constraints: 1 ≤ |arr1|, |arr2| ≤ 10^5; −10^9 ≤ values ≤ 10^9.
Code runner format: one JSON value per line: arr1, then arr2. Implement firstGreaterIndex(arr1, arr2); the harness prints the list as JSON.