Invalid Transactions in Time Order
Updated
Problem statement
Each string in transactions has the form name,time,amount,city. The array is already sorted by nondecreasing integer time.
A transaction is invalid when at least one condition holds:
amount > 1000.- Another transaction has the same
name, occurs within 60 minutes inclusive, and has a differentcity.
Return every invalid original transaction string in input order. A conflicting pair makes both transactions invalid.
Function
invalidTransactionsSorted(transactions: String[]) → String[]Examples
Example 1
transactions = ["alice,20,800,mtv","alice,50,1200,mtv"]return = ["alice,50,1200,mtv"]The second amount exceeds 1000. The shared city means the first transaction is not invalidated by the time rule.
Example 2
transactions = ["alice,20,800,mtv","alice,50,100,beijing"]return = ["alice,20,800,mtv","alice,50,100,beijing"]The two transactions share a name, differ in city, and are 30 minutes apart, so both are invalid.
Example 3
transactions = ["alice,20,800,mtv","alice,90,100,beijing","bob,100,100,mtv"]return = []Alice's transactions are 70 minutes apart, and Bob has no same-name comparison.
Constraints
1 <= transactions.length <= 100000.- Each row has exactly four comma-separated fields.
nameandcitycontain 1 through 20 lowercase English letters.0 <= time <= 10^9, and input times are nondecreasing.0 <= amount <= 10^9.
More Bloomberg LP Onsite Interview questions
- Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Incident MonitorStripe · OAStripe interview questions
- Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
- Shortest Window with Required CountsOracle · ONSITE INTERVIEWOracle interview questions
- Count Zero Request ServersSalesforce · ONSITE INTERVIEWSalesforce interview questions
- Compact Conversations by Unique ListingsSierra · PHONE SCREENSierra interview questions
- Find Word-Multiset WindowsAmazon · PHONE SCREEN
- High-Traffic IPs in a Sliding WindowGoogle · ONSITE INTERVIEWGoogle interview questions
- Flat Records to a Hierarchical TreeAddepar · PHONE SCREEN
- Product Total With the Cheapest PromotionInstacart · ONSITE INTERVIEWInstacart interview questions
- Count Equal Code Pairs Within Distance KInfosys · ONSITE INTERVIEWInfosys interview questions