Stripe OA真题:Merchant Fraud Score Stripe OA Question – OA代写 -面试真题 – 代面试

The fraud detection team at Stripe aims to reduce merchant fraud risk for Stripe with minimal pain to good merchants through machine learning. To provide initial data for training this machine learning model, you are tasked with developing a system to assess the fraud risk associated with transactions made to various merchants.

Description

You are given transactions_list which is a list of transactions for a certain day, merchants_list which is a list of merchants, and rules_list which is a list of rules corresponding to each transaction.

A transaction denotes a payment made by a customer to a merchant. Each merchant in merchants_list is assigned a base_score.

Your task is to assign each merchant a fraud score based on their transaction(s), where each transaction can have different risk factors based on certain categories, e.g. transaction amount, frequency of similar transactions, user activity.

To do this:

  • Initialize a merchant's current_score as their base_score.
  • For each transaction in the transactions_list, calculate and update the merchant's current_score. This should be done in separate passes over the entire list for each step:
    • If the transaction amount is greater than the corresponding rule's min_transaction_amount, multiply current_score by the corresponding rule's multiplicative_factor.
    • If the same customer_id has made three or more transactions to that merchant_id including the current transaction, add all the corresponding rules' additive_factors to current_score, cumulatively. For example, if the merchant's score at the third transaction is X, which includes the first, second, and third additive_factors, the fourth transaction should be: X + the fourth transaction additive_factor
    • If a transaction is the third or more from the same customer_id in the same hour for the same merchant_id including the current transaction, do the following:
      • If the hour is between 12 to 17 inclusive: Add the penalty each time. This includes the first and second transactions as well as all the ones after the third.
      • If the hour is between 9 to 11, or 18 to 21 inclusive: Subtract the penalty each time. This includes the first and second transactions as well as all the ones after the third.
      • If the hour falls outside the above ranges, don't do anything.

Input

Note: You may assume that there won't be any integer overflows.

  • transactions_list: A list of length n where 1 <= n <= 1000, where each transaction is represented as a comma-separated string.
    • A string merchant_id with length > 0, representing the merchant who receives payment.
    • An integer amount, representing the amount of the payment.
    • A string customer_id with length > 0, representing the customer who makes payment.
    • An integer hour, where 0 <= hour <= 23, representing the hour of the transaction.
  • rules_list: A list of length n where 1 <= n <= 1000, where each rule is represented as a comma-separated string and corresponds to each transaction in transactions_list.
    • An integer min_transaction_amount of the corresponding transaction to consider fraudulent.
    • An integer multiplicative_factor.
    • An integer additive_factor.
    • An integer penalty.
  • merchants_list: A list of length m, where 1 <= m <= 1000, where each item is a merchant profile represented as a comma-separated string that gives additional context for the score.
    • A string merchant_id with length > 0, representing the merchant who receives payment.
    • An integer base_score, where 1 <= base_score <= 50. Represents the base risk score of the merchant.

Output

Return a list of comma-separated strings denoting the merchants in lexicographical order and their fraud scores.

Example Input

n = 6

transactions_list = [
"merchant1,1200,customer1,10",
"merchant1,500,customer1,10",
"merchant2,2400,customer1,15",
"merchant1,800,customer1,16",
"merchant1,1000,customer2,17",
"merchant1,1400,customer1,10",
]

rules_list = [
"1000,2,8,15",
"1400,5,3,19",
"2300,3,17,3",
"1800,2,9,6",
"1000,4,8,2",
"1200,3,11,7",
]

m = 2

merchants_list = [
"merchant1,10",
"merchant2,20",
]

Example Output

[
"merchant1,50", # 10 -> 10*2=20 -> 20*3=60 -> 60+8+3+9+11=91 -> 91-15-19-7=50
"merchant2,60" # 20 -> 20*3=60
]

我们也有代面试,面试辅助,OA代写等服务助您早日上岸~

Leave a Reply

Your email address will not be published. Required fields are marked *