Invalid Transactions
Updated
Problem statement
Given transactions, return every invalid string unchanged and in input order.
Each string has the form name,time,amount,city.
A transaction is invalid if either condition holds:
amount > 1000.- Another transaction has the same
nameand a differentcity, and their times differ by at most 60 minutes.
Both transactions in such a pair are invalid.
Function
invalidTransactions(transactions: String[]) → List<String>Examples
Example 1
transactions = ["alice,20,800,mtv","alice,50,1200,mtv"]return = ["alice,50,1200,mtv"]Only the second transaction is invalid because its amount exceeds 1000. Both transactions are in the same city, so the first is valid.
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,90,100,beijing","bob,100,100,mtv","alice,20,800,mtv"]return = []Alice's transactions are 70 minutes apart, and Bob has only one transaction. All transactions are valid, so the result is empty.
Constraints
1 <= transactions.length <= 1000.- Each row has exactly four comma-separated fields.
nameandcitycontain 1 through 20 lowercase English letters.0 <= time <= 1000.0 <= amount <= 2000.
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
- Group AnagramsAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
- Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
- Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
- Shortest Uncommon SubstringAirbnb · ONSITE INTERVIEWAirbnb interview questions
- Longest Consecutive Login StreakAmazon · ONSITE INTERVIEW
- Group AnagramsWorkday · PHONE SCREEN
- Apply Operations to Make a String EmptyFlexport · PHONE SCREENFlexport interview questions
- Group AnagramsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Group AnagramsEPAM · PHONE SCREENEPAM interview questions
- Underline Shortest Unique SubstringsMoveworks · PHONE SCREENMoveworks interview questions