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
▲ Console
📱

Install Talent Enrich

Get instant access to jobs and career tools on your device.