All problems
0557MediumArrayHash TableStringSorting

Flagged Expense Claims

Tracked in this browser only
Write code

Trains the technique from

LeetCode 1169Invalid Transactions

This is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.

Same function shape, different story and different numbers.

An audit tool receives a day's expense claims as a list of strings. Each entry of transactions has the form "{staff},{minute},{amount},{site}", giving the person who filed it, the minute of the day it was filed, the sum claimed, and the office site it was filed from.

A claim is flagged when either of these holds:

  • the amount claimed is more than 1200, or
  • some other claim in the list carries the same staff name, was filed from a different site, and its minute is within 60 of this claim's minute (a gap of exactly 60 counts as within).

Return the flagged claims as the original strings, in any order. Two entries may be byte-for-byte identical; each is judged separately, so each flagged copy appears in the result.

Examples

Example 1

Input
transactions = ["dana,120,300,leeds", "dana,180,300,york", "elias,400,1300,leeds"]
Output
["dana,120,300,leeds", "dana,180,300,york", "elias,400,1300,leeds"]

Dana's two claims are 60 minutes apart from different sites, which is within the window, so both are flagged. Elias claims 1300, which is above 1200.

Example 2

Input
transactions = ["kai,10,200,perth", "kai,20,200,perth"]
Output
[]

Both claims come from the same site, so the second rule does not apply, and neither amount is above 1200.

Example 3

Input
transactions = ["mira,300,1500,derby", "mira,300,1500,derby"]
Output
["mira,300,1500,derby", "mira,300,1500,derby"]

The two entries are identical and each claims 1500, so each one is flagged on the amount rule and both copies are reported.

Constraints

  • 1 <= transactions.length <= 1000
  • Each transactions[i] has the form "{staff},{minute},{amount},{site}"
  • staff and site consist of lowercase English letters and have length between 1 and 10.
  • minute is an integer written in digits, between 0 and 1000.
  • amount is an integer written in digits, between 0 and 2000.
  • The result may be returned in any order.

The values you return may be in any order.

The signature

The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.

Python
def invalid_transactions(transactions: list[str]) -> list[str]:
Java
public List<String> invalidTransactions(String[] transactions)
September 7
Apply