Next Greater Element I
Easy
Stacks
Array
Stack
Hash Table
For each element in nums1 (subset of nums2), find next greater in nums2. -1 if none.
Constraints
1 ≤ len ≤ 1000
Examples
Example 1:
Input: 4 1 2
1 3 4 2
Output: -1 3 -1
Example 2:
Input: 2 4
1 2 3 4
Output: 3 -1
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console