←ENG-DSA-001Payment System Double-Billing (Array)
00:00
🐍 Python Idle
Mode:Web

Payment System Double-Billing (Array)

CompaniesStripe, Square
Est. Time~20 min
LevelJunior
ArraysHash SetCycle Detection
🚨 P0 Incident
StripeSquare

Stripe processes millions of payment transactions per day. A subtle bug in the idempotency layer caused certain transactions to be submitted twice, resulting in customers being double-charged. The transaction log is an array of N+1 integers where every integer is in the range [1..N] β€” meaning exactly one ID appears twice. The billing team has escalated this as a P0 incident.

πŸ“₯ Assigned to:You β€” Junior Engineer
Your Task

Finance flagged that 3 customers were charged twice. The transaction log array has N+1 items in range [1..N], containing exactly one duplicate ID. Find it in O(n) time and O(1) space.

⏱ Time: O(n)πŸ’Ύ Space: O(1)
Example 1
Input:Β Β nums = [1, 3, 4, 2, 2]
Output:Β 2
Example 2
Input:Β Β nums =[3, 1, 3, 4, 2]
Output:Β 3
πŸ”’ +3 hidden test cases β€” revealed on Submit
Hints
Loading editor…
Test Output
β–Ά Run Code to test against examples Β· Submit to judge all 5 test cases
EngPrep β€” Real Engineering. Real Interviews.