Throttle — LeetCode 2676 Python Solution

MediumLeetCode PremiumJavaScript
Problem
#2676
Reading time
2 min

The problem

Given a function fn and a time in milliseconds t, return a throttled version of that function. A throttled function is first called without delay and then, for a time interval of t milliseconds, can't be executed but should store the latest function arguments provided to call fn with them after the end of the delay.

Example

Input
t = 100,
Output
[{"t":20,"inputs":[1]}]
Explanation
The 1st call is always called without delay

Complexity

MeasureComplexity
TimeO(n)
SpaceO(1) to O(n) auxiliary

Related problems

Frequently asked questions

How hard is LeetCode 2676. Throttle?
LeetCode 2676. Throttle is rated Medium on LeetCode.
What topics does LeetCode 2676. Throttle cover?
LeetCode 2676. Throttle is tagged JavaScript on LeetCode.
Is LeetCode 2676. Throttle a premium problem?
Yes. LeetCode 2676. Throttle is a LeetCode Premium problem, so the full statement and test cases require a paid LeetCode subscription.

Stuck on problems like this in a live interview?

Stealth Interview is a desktop app for macOS and Windows. It reads the problem off your screen and returns a working solution with a step-by-step explanation and its time and space complexity — invisible to screen sharing.

Get Stealth Interview