2020 Account Balance with Monthly Card Fees
Updated
Problem statement
An account records transactions during calendar year 2020. Arrays A and D describe the transactions: A[i] is the signed amount, and D[i] is its date in YYYY-MM-DD format.
Every amount contributes directly to the account balance. A negative amount is a card payment.
The account normally pays a fee of 5 for each of the twelve months. The fee for a month is waived only when that month contains at least three card payments whose combined absolute value is at least 100.
Starting from balance 0, return the final balance after all transactions and all applicable monthly fees.
Function
solution(A: int[], D: String[]) → intExamples
Example 1
A = [100,-30,-40,-30]D = ["2020-01-01","2020-01-10","2020-01-20","2020-01-30"]return = -55The transaction amounts sum to 0. January has three card payments totaling 100, so its fee is waived. The other eleven monthly fees total 55.
Example 2
A = [100]D = ["2020-12-01"]return = 40No month qualifies for a waiver, so twelve fees totaling 60 are subtracted from the transaction total of 100.
Constraints
A.length == D.length.- Every value in
Dis a valid date in calendar year2020usingYYYY-MM-DDformat.
More DRW Online Assessment questions
- Count Balanced Nodes in a Rooted TreeOA · Seen Sep 2026
- Largest Number With Even Digit FrequenciesOA · Seen Sep 2026
- Shortest Path Around Rectangular ObstaclesOA · Seen Sep 2026
- Nested In-Memory Database TransactionsOA · Seen Aug 2026
- Password Requirement CheckOA · Seen Aug 2026
- Remove Excess Consecutive CharactersOA · Seen Aug 2026
- Last Round for Each PlayerOA · Seen Jul 2026
- Shortest Compressed Length After RemovalOA · Seen Jul 2026
- Doctor Appointment Slot AssignmentOA · Seen Jul 2026
- Maximum Even-Sum Neighboring PairsOA · Seen Jul 2026
Similar questions at other companies
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Diagonal Bounce TraversalAutodesk · OAAutodesk interview questions
- Costliest ChocolateRippling · OARippling interview questions
- Online No-Intercept Linear RegressionTwo Sigma · OATwo Sigma interview questions
- Plus Mult ArrayIBM · OAIBM interview questions
- Progressive Tax CalculatorInteractive Brokers · OA
- Array Challenge (QR Intern)Akuna Capital · OAAkuna Capital interview questions
- Latency Bucket CounterDatadog · OA · PHONE SCREENDatadog interview questions
- First Fibonacci Number at Least the Array SumBitGo · OABitGo interview questions
- Metro Fare With a Daily CapMicrosoft · OAMicrosoft interview questions