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.

Input Format

Input is managed for you

Output Format

Output is managed for you

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

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
4 1 2
1 3 4 2
Output
3
-1
3
-1
Previous
Next Greater Element To The Right
Next
Next Greater Element Ii

Related Questions