Stock Price Range over a Sliding Day Window
Updated
Problem statement
Return maximum minus minimum among the most recent k prices in stockPrices. If k exceeds the number of prices, use the full history. Return -1 for empty input.
Function
stockPriceRange(stockPrices: int[], k: int) → intExamples
Example 1
stockPrices = [4,1,8,2]k = 2return = 6The latest prices are 8 and 2.
Constraints
k > 0.- At most
10^5prices.
More Bloomberg LP Onsite Interview questions
- Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- 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
- Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Bad Request AlertsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Fixed-Window Rolling MeanJump Trading · ONSITE INTERVIEWJump Trading interview questions
- Sliding-Window Text ChunkingSAP · ONSITE INTERVIEW
- Duplicate Transactions Within 60 SecondsCapital One · ONSITE INTERVIEWCapital One interview questions
- Sliding Window Average (Meta Canada, E4/E5 :)Meta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
- Maximum Earnings Across WarehousesAmazon · ONSITE INTERVIEW
- Shortest Subarray with Sum at Least KOracle · ONSITE INTERVIEWOracle interview questions
- Count Zero Request ServersSalesforce · ONSITE INTERVIEWSalesforce interview questions
- Longest Subarray Within an Absolute-Difference LimitGoogle · ONSITE INTERVIEWGoogle interview questions
- Longest Binary Subarray With at Most K OnesLinkedIn · ONSITE INTERVIEWLinkedIn 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)