Skip to interview prep
Apexed

38. Report First Regional Quota Crossings

EasyAPI quotas

Limits are [region, quota] pairs. Usage events are [region, units] in arrival order. Start each region at zero and ignore usage from regions with no limit.

Return [region, zero-based event index] for the first event that makes each region strictly exceed its quota, in order of occurrence.

Example 1

Input: limits = [["east",5],["west",2]], usage = [["east",5],["west",3],["east",1],["west",2]]
Output: [["west",1],["east",2]]

Example 2

Input: limits = [["north",0]], usage = [["north",0],["south",20],["north",1],["north",1]]
Output: [["north",2]]

Constraints

  • At most 100,000 limits and usage events each. Limit regions are unique.
  • Quotas and units are integers in [0, 10⁶].

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 5 hidden and sample tests.

Code runs in an isolated browser sandbox. Progress and submissions are saved on this device.

Report First Regional Quota Crossings — coding interview practice — Apexed