Throttled Call Times
Updated
Problem statement
A throttled function does its work at most once in any stretch of wait time units, however often it is called. Calls that come too soon after the last run are simply dropped.
Call i happens at time times[i] with value values[i]. The rules:
- A call runs immediately, at its own time and with its own value, if nothing has run yet or if at least
waittime units have passed since the latest run (times[i] - lastRun >= wait). - Any other call is dropped. A dropped call is never run later.
- Calls at the same time are handled in the order they are given.
Return every run as a pair [run time, value], in time order.
Function
throttledRuns(times: int[], values: int[], wait: int) → int[][]Examples
Example 1
times = [0,2,3,5,9,10,14]values = [1,2,3,4,5,6,7]wait = 4return = [[0,1],[5,4],[9,5],[14,7]]The call at 0 runs. Calls at 2 and 3 are less than 4 after it and are dropped. The call at 5 runs (5 after the last run), and so does the call at 9, exactly 4 after 5. The call at 10 is dropped and the call at 14 runs.
Example 2
times = [3,3,3]values = [8,9,10]wait = 1return = [[3,8]]The first call at time 3 runs. The other two arrive 0 time units after that run, which is less than 1, so they are dropped.
Example 3
times = [1,100]values = [5,6]wait = 50return = [[1,5],[100,6]]The calls are 99 apart, more than 50, so both run.
Constraints
1 <= times.length <= 1000andvalues.length == times.length0 <= times[i] <= 10^6, andtimesis sorted in non-decreasing order0 <= values[i] <= 10^41 <= wait <= 10^6
More Adobe Phone Screen questions
- Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
- All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
- Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
- Binary Tree Level-Order Traversal by LevelsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
- Count Occurrences in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
- Count Pairs with Absolute Difference KPHONE SCREEN · Seen Jul 2026
- Count Subsets with Sum KPHONE SCREEN · Seen Jul 2026
- Numbers with Exactly Three DivisorsPHONE SCREEN · Seen Jul 2026
- Sum of Even Nodes on a Path in a Numbered Binary TreePHONE SCREEN · Seen Jul 2026
- Largest Value in Every Sliding WindowPHONE SCREEN · Seen Jul 2026
Similar questions at other companies
- Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREENPlaid interview questions
- Search and Format ContactsAdyen · PHONE SCREENAdyen interview questions
- Array-Backed Set Without Library CollectionsOde with Anthropic · PHONE SCREEN
- Paginate Retained Conversation HistorySierra · PHONE SCREENSierra interview questions
- Validate a Chess Bishop, Rook, or Queen MoveGlean · PHONE SCREENGlean interview questions
- Count Distinct Underwriting PII ValuesAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
- Apply Affine Array TransformationsByteDance · PHONE SCREENByteDance interview questions
- Match a Variadic Function SignatureConfluent · PHONE SCREENConfluent interview questions
- Bounded IPv4 FilterAmazon · PHONE SCREEN
- Partition and Group Values by ParityEPAM · PHONE SCREENEPAM interview questions