FastPrepWallet Balance on a Selected Day
Problems/Wallet Balance on a Selected Day

Wallet Balance on a Selected Day

BharatPe logoBharatPe● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a BharatPe full-time phone screen. The report asks for the balance on a chosen day, given by an array index, from wallet debit and credit data. It does not say how the data is written. Here there is one signed transaction per day and the opening balance is zero. Our version is about 92% the same as the reported question.

A wallet starts with balance 0. Its daily transactions are stored in an integer array transactions: a positive value is a credit, a negative value is a debit, and zero makes no change.

Given a zero-based index selectedDay, return the wallet balance at the end of that day. Include every transaction from day 0 through selectedDay. Return a 64-bit integer.

Function

balanceOnDay(transactions: int[], selectedDay: int) → long

Examples

Example 1

transactions = [100,-30,20,-10]selectedDay = 2return = 90

After days 0 through 2, the balance is 100 - 30 + 20 = 90.

Example 2

transactions = [-50,80,-20]selectedDay = 0return = -50

Only the first day's debit is included.

Example 3

transactions = [5,0,-2,7]selectedDay = 3return = 10

The full history sums to 5 + 0 - 2 + 7 = 10.

Constraints

  • 1 <= transactions.length <= 5000
  • -10^6 <= transactions[i] <= 10^6
  • 0 <= selectedDay < transactions.length

More BharatPe Phone Screen questions

  • Merge K Sorted Linked ListsPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Calculate Server Shutdown PenaltyStripe · PHONE SCREEN · ONSITE INTERVIEWStripe interview questions
  • Instrument Stack Language JumpsJane Street · PHONE SCREENJane Street interview questions
  • Schedule Buffered Video PlaybackNuro · PHONE SCREENNuro interview questions
  • Online No-Intercept Linear RegressionTwo Sigma · OATwo Sigma interview questions
  • Array Challenge (QR Intern)Akuna Capital · OAAkuna Capital interview questions
  • Range Negation UpdatesJP Morgan Chase · OAJP Morgan Chase interview questions
  • Data UpdatesExpedia · OAExpedia interview questions
  • Hall of Shifting TilesAdobe · OAAdobe interview questions
  • Weighted Lottery WinnersAmazon · ONSITE INTERVIEW
  • Prefix Scores With the Running MaximumC3.ai · OAC3.ai interview questions
See BharatPe hiring insights
Saved
class Solution {
    public long balanceOnDay(int[] transactions, int selectedDay) {
        // write your code here
    }
}
Checking account…