Next Greater Element I
Updated
Problem statement
You are given two arrays of distinct integers, query and reference, where every query value appears in reference.
For each query value, return the first greater value to its right in reference, or -1 when none exists.
Function
nextGreaterElement(query: int[], reference: int[]) → int[]Examples
Example 1
query = [4,1,2]reference = [1,3,4,2]return = [-1,3,-1]Four and two have no greater value to their right; one is followed by three.
Example 2
query = [2,4]reference = [1,2,3,4]return = [3,-1]Three is the next greater value after two, while four has none.
Constraints
1 <= query.length <= reference.length <= 10^5.- All values in each array are distinct.
- Every value in
queryappears inreference.
More Bloomberg LP Phone Screen questions
- Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026
Similar questions at other companies
- Next Greater Element IEPAM · PHONE SCREENEPAM interview questions
- Most Frequent Call Path From Function Trace LogsRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
- KV Store with Nested TransactionsApplied Intuition · PHONE SCREEN · ONSITE INTERVIEWApplied Intuition interview questions
- Validate a BST with a Custom ComparisonApple · PHONE SCREENApple interview questions
- Recipe Cart with Undo and RedoDecagon · PHONE SCREENDecagon interview questions
- Layer History with Batch Undo and RedoFigma · OA · PHONE SCREENFigma interview questions
- Construct a Tree from Level-Order and Inorder TraversalsAmazon · PHONE SCREEN
- In-Memory Database with Transactions and SavepointsNextdoor · PHONE SCREENNextdoor interview questions
- Who Is in the Room?WhatNot · PHONE SCREENWhatNot interview questions
- Configurable Valid BracketsMaven Clinic · PHONE SCREEN · ONSITE INTERVIEWMaven Clinic interview questions
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)