⌘K
Flycodx

Bank Account Overdraft Detection

Bank Account Overdraft Detection

MediumArrays100% accepted

Arjun tracks his ICICI bank account transactions in Mumbai. An array contains debits (negative) and credits (positive). He needs to identify all transaction indices where his account balance went negative (overdraft), which triggers penalty fees. Rule: starting balance is 0; process transactions in order and return all 0-based indices where the running balance is negative after the transaction. Return [] if none. Your solve(...) function receives the inputs as ready-made arguments — no input reading or parsing needed; just return the answer.

Approach

Given an array of transactions (positive for deposits, negative for withdrawals), find all indices where cumulative balance becomes negative.

Input

transactions=[1000,-200,-150,500,-100,-80,-300]

Output

[]
solution.py
Loading editor...
Test 1
Test 2
Test 3

Press Run to test your custom input, or Submit to judge against all test cases.

Sign in to continue

Create a free account to run code, submit solutions and track progress.

  • Free forever — no credit card
  • 10+ languages with live execution
  • Points, streaks & leaderboards
Auto Save OnLn 1, Col 1Spaces: 4UTF-8LFPython 3