Products of the Current Minimum and Maximum
Updated
Problem statement
Start with an empty collection of integers. Process operations and the corresponding values in x in order.
pushinserts one occurrence of the given value.popremoves one occurrence of the given value. That occurrence is guaranteed to exist.
After every operation, append the product of the current minimum and maximum values to the result. For this exercise, repeated values are separate occurrences; removing one does not remove the others. When the collection is empty, append 0. Return all products in order.
Function
maxMin(operations: String[], x: int[]) → long[]Examples
Example 1
operations = ["push","push","push","pop"]x = [3,8,2,8]return = [9,24,16,6]The collections are [3], [3,8], [3,8,2] and [3,2]. Their minimum/maximum products are 9,24,16,6.
Example 2
operations = ["push","push","pop","pop"]x = [4,4,4,4]return = [16,16,16,0]Each pop removes one copy of 4. One copy remains after the first pop, so its product is still 16. The last pop empties the collection and gives 0.
Constraints
- 1 <= operations.length <= 100000.
- operations.length equals x.length.
- 1 <= x[i] <= 1000000000.
- Every operation is push or pop. Each pop removes a value that is currently present.
Source note: Original OA task images and any included source example. The practice contract follows the rules stated in the problem and source note.
More Adobe Online Assessment questions
- Base Unit ConversionsOA · Seen Nov 2026
- Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
- Top-Funded Villages and ProjectsOA · Seen Aug 2026
- Count Parent Nodes With a Target SumOA · Seen Aug 2026
- Largest Binary Number by ConcatenationOA · Seen Aug 2026
- Count Events by CategoryOA · Seen Aug 2026
- Graph M-ColoringOA · Seen Aug 2026
- Hall of Shifting TilesOA · Seen Aug 2026
- K-th Ancestor Subtree Preorder QueryOA · Seen Aug 2026
- Maze ReachabilityOA · Seen Aug 2026
Similar questions at other companies
- Top K Frequent ElementsAmazon · OA · PHONE SCREEN · ONSITE INTERVIEW
- Rearrange Songs by AuthorZomato / Eternal · OAZomato / Eternal interview questions
- Auction Sniping Window MinimumCisco · OACisco interview questions
- Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
- Top K Frequent ElementsCapgemini · ONSITE INTERVIEWCapgemini interview questions
- Top K Frequent Elements with Larger-Value Tie BreakOracle · ONSITE INTERVIEWOracle interview questions
- Top K Frequent ElementsInfosys · ONSITE INTERVIEWInfosys interview questions
- Top K Frequent ElementsGoogle · PHONE SCREENGoogle interview questions
- Top K Frequent ElementsBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
- Top K Frequent ElementsApple · PHONE SCREENApple interview questions
Adobe interview experiences
- Adobe New Grad OA: Unit Conversion and Code Review: 1 Experience
- Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
- Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
- Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
- Adobe New Grad MTS Interview Questions: 7 Experiences
- Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)