Find next greater element for subset
Company: Pinduoduo
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Onsite
Quick Answer: This question evaluates understanding of sequence analysis and array-processing competencies, including mapping elements between arrays, index lookup, and designing efficient order-dependent algorithms for the "next greater element" problem.
Examples
Input: ([4, 1, 2], [1, 3, 4, 2])
Expected Output: [-1, 3, -1]
Explanation: Prompt example.
Input: ([2, 4], [1, 2, 3, 4])
Expected Output: [3, -1]
Explanation: One has no greater.
Input: ([1], [1])
Expected Output: [-1]
Explanation: Single value.