Biggest Daily Move and Longest Rising Streak
Updated
Problem statement
You are given the closing price of one stock over n trading days. prices[i] is the price in cents on day i, where days are numbered from 0.
The move on day i (for i >= 1) is the absolute change from the day before, |prices[i] - prices[i - 1]|. A rising streak is a run of consecutive days on which the price is strictly higher than on the day before; its length is the number of those days.
Return an array [moveDay, longestStreak]:
moveDayis the day with the largest move. If several days share the largest move, use the earliest of them.longestStreakis the length of the longest rising streak, or0if the price never rises.
Function
priceScan(prices: int[]) → int[]Examples
Example 1
prices = [100,102,98,99,101,104,103]return = [2,3]The daily moves are 2, 4, 1, 2, 3, 1. The biggest is 4, from 102 on day 1 to 98 on day 2, so the first value is 2. From day 2 the price rises on days 3, 4 and 5 (98 < 99 < 101 < 104), a streak of 3 rising days.
Example 2
prices = [50,40,30]return = [1,0]Both moves are 10, so the earlier day, day 1, wins the tie. The price never rises, so the longest streak is 0.
Example 3
prices = [1,3,2,4,6]return = [1,2]The moves are 2, 1, 2, 2 on days 1 to 4. Days 1, 3 and 4 tie for the biggest move, and day 1 is the earliest. The price rises on days 3 and 4 (2 < 4 < 6), a streak of 2.
Constraints
2 <= prices.length <= 2 * 10^41 <= prices[i] <= 10^6
More Jane Street interview questions
- Product Profit SummaryOA · Seen Sep 2026
- Cheating CodemakerOA · Seen Mar 2026
- Bond Haircut by Ratings and MaturityOA · Seen Aug 2024
- Currency Haircut with FX ForwardsOA · Seen Aug 2024
- Transform StringOA · Seen Jul 2024
- Price Deviation AlertsOA · Seen Nov 2023
- Trade Blotter Summary by TickerOA · Seen Jun 2021
- Transaction Fees by InstrumentOA · Seen Mar 2018
- Maximum-Scoring Consecutive Tree LevelsPHONE SCREEN · Seen Nov 2026
- Tree Selection and VisibilityPHONE SCREEN · Seen Nov 2026
Similar questions at other companies
- Missing IntervalsIBM · OAIBM interview questions
- Total Cost Against the Lowest Earlier PricePayPal · OAPayPal interview questions
- Bad Request AlertsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Confusing Bib NumbersVerily · ONSITE INTERVIEW
- Count User Mentions in Chat MessagesRamp · OARamp interview questions
- Group Transactions by HourAffirm · ONSITE INTERVIEWAffirm interview questions
- Count Valid Square PairsAuxoAI · OA
- Longest Common PrefixKotak Mahindra Bank · PHONE SCREEN · ONSITE INTERVIEWKotak Mahindra Bank interview questions
- Rotate a Matrix by 90 DegreesIDFC Bank · ONSITE INTERVIEWIDFC Bank interview questions
- Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions