Reported September 2026
Arista Networksdynamic programming

API Bandwidth Allocation

Reported by candidates from Arista Networks's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Arista Networks OA. Under 2s to a working solution.
Founder's read

Each endpoint in this Arista Networks problem either gets enabled once or it doesn't, and your bandwidth budget is a hard cap. That's a 0/1 knapsack in an API costume. It was reported in September 2026, and the setup is clean: bandwidth is the weight, requests resolved is the value, maxBandwidth is capacity. If you spot the knapsack in the first minute, the rest is a short loop. If you blank on the DP state, StealthCoder is the safety net that runs invisibly during the live OA and hands you the solution. Know the shape either way.

The problem

Each API endpoint consumes bandwidth[i] units when enabled and resolves requests[i] requests. An endpoint is either enabled once or not enabled.
Given the total available maxBandwidth, return the maximum number of requests that can be resolved without exceeding the bandwidth limit.

Function
maximizeResolvedRequests(maxBandwidth: int, bandwidth: int[], requests: int[]) → int

Examples
Example 1
maxBandwidth = 5
bandwidth = [2,3,4]
requests = [4,5,7]
return = 9
Case 1 exercises the documented deterministic contract.
Example 2
maxBandwidth = 7
bandwidth = [2,3,4]
requests = [4,5,7]
return = 12
Case 2 exercises the documented deterministic contract.
Example 3
maxBandwidth = 0
bandwidth = [1,2]
requests = [10,20]
return = 0
Case 3 exercises the documented deterministic contract.

Constraints
0 <= maxBandwidth <= 10000.
1 <= bandwidth.length == requests.length <= 200.
1 <= bandwidth[i] <= 10000.
0 <= requests[i] <= 10^6.
The optimal answer fits a signed 32-bit integer.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is recognizing 0/1 knapsack. Build dp[w] as the max requests resolved using at most w bandwidth. For each endpoint, loop w from maxBandwidth down to bandwidth[i] and set dp[w] = max(dp[w], dp[w - bandwidth[i]] + requests[i]). The backward loop is the whole point. Go forward and you reuse an endpoint multiple times, which turns it into unbounded knapsack and breaks Example 2 (you'd get more than 12). Greedy by ratio also fails, so don't trust it. Check the edge: maxBandwidth = 0 returns 0 because every bandwidth[i] is at least 1. With 200 items and capacity 10000, that's about 2 million operations, which is fine. If the DP state slips away mid-assessment, StealthCoder is the hedge that reads the problem and gives you the working code.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill API Bandwidth Allocation cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Arista Networks's OA.

Arista Networks reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

API Bandwidth Allocation FAQ

What's the trick in the Arista Networks API Bandwidth Allocation problem?+

It's 0/1 knapsack. Bandwidth is the item weight, requests is the value, maxBandwidth is the capacity. Each endpoint is used at most once, so you iterate capacity backward in a 1D DP array to avoid reusing an item.

Why does greedy by requests per bandwidth fail?+

Picking the best ratio first can leave unused capacity that a different combination would fill better. With bandwidth [2,3,4] and a cap of 5, you need to compare combinations, not just sort by ratio. DP checks every valid subset implicitly.

What's the time and space complexity?+

Time is O(n * maxBandwidth) and space is O(maxBandwidth) with the 1D array. With n up to 200 and maxBandwidth up to 10000, that's roughly 2 million steps. It runs fast and the answer fits in a 32-bit integer per the constraints.

What edge cases should I test before submitting?+

Test maxBandwidth = 0, which must return 0. Test an endpoint whose bandwidth exceeds the cap, which should be skipped. Test requests[i] = 0 entries. Also confirm Example 2 returns 12, since that catches the forward-loop reuse bug.

How do I prepare for this in 48 hours?+

Write the 1D 0/1 knapsack from memory twice. Focus on the backward capacity loop and the dp[w] meaning. Then run the three given examples by hand. Knapsack variants show up often, so the pattern transfers to similar questions on the same OA.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Arista Networks.

OA at Arista Networks?
Invisible during screen share
Get it