Next Greater Element I
easy
1: You are given two integer arrays query and nums containing unique elements. 2: Here query is a subset of nums that means all elements of query are also present in nums. 3: Find all the next greater numbers for query's elements in the corresponding places of nums. If it does not exist -1 is answer for this number. 4: You are required to complete the body of the function nextGreaterI(int nums[], int query[]) which returns the answer array containing next greater element's.
Constraints
1: 1 <= query.length <= nums.length <= 1000 2: 0 <= query[i], nums[i] <= 10^9 3: All integers in query and nums are unique. 4: All the integers of query also appear in nums
Format
Input
Input is managed for you
Output
Output is managed for you
Example
Sample Input
4 1 2
1 3 4 2
Sample Output
3
-1
3
-1
Question Video