#C14219. Suspicious Transaction Analysis

    ID: 43844 Type: Default 1000ms 256MiB

Suspicious Transaction Analysis

Suspicious Transaction Analysis

Your task is to analyze a list of transactions. Each transaction record contains a transaction ID, a from account, a to account, and an amount, separated by a comma and a space. A transaction is considered suspicious if it meets one or both of the following criteria:

  • The FROM_ACCOUNT is the same as the TO_ACCOUNT (flagged as same_account).
  • The AMOUNT exceeds \(1000.00\) (flagged as high_amount).

If a transaction meets any of these criteria, output its transaction ID along with the corresponding reason(s) in a JSON array. Each element in the array should be a JSON object with a key TRANSACTION_ID and a key reason which is an array of one or more flags. If no transaction is suspicious, output an empty JSON array.

inputFormat

The input is read from stdin. The first line contains an integer \(n\), the number of transactions. This is followed by \(n\) lines, each representing a transaction record in the following format:

TRANSACTION_ID, FROM_ACCOUNT, TO_ACCOUNT, AMOUNT

Note: AMOUNT is a floating point number and the fields are separated by a comma and a space.

outputFormat

Output the suspicious transactions to stdout as a JSON array. Each element in the array is a JSON object with the following keys:

  • TRANSACTION_ID: the transaction ID as a string.
  • reason: an array of strings indicating the suspicious criteria (i.e., same_account and/or high_amount).

If there are no suspicious transactions, output an empty JSON array ([]).

## sample
1
123456, 1001, 1001, 500.00
[{"TRANSACTION_ID": "123456", "reason": ["same_account"]}]