For the best experience, increase the window size or view on a laptop or desktop device
Title | ||
|---|---|---|
Loading... | ||
For the best experience, increase the window size or view on a laptop or desktop device
Title | ||
|---|---|---|
Loading... | ||
Imagine you are creating the backend for an app called StripePay (the next popular peer to peer payment method) that allows Stripe users to send each other money and transfer money to and from their bank accounts. Stripe users make thousands of transactions every day, so we need functionality that handles balance changes, transactions, and balance reads.
Please read the entire prompt before you start coding. Not all the test cases will pass unless all the constraints are met.
We will implement the core of the backend: users sending money to each other. However, our networks can be a bit unreliable, so sometimes we get transactions out of order; therefore, we must execute each command in chronological order. Additionally, StripePay users send each other money and transfer money to and from their connected bank accounts.
Given a list of commands for an account balance API, you will have to parse each command and return a comma-separated string of the command results in sequential order of the commands received, but they must be executed in chronological order. There can be at most 1 command per second. Some of the supported commands are:
INIT,name,balance,bank_1,bank_2,...,bank_n
POST,timestamp,sender,receiver,amount
FAILURE.FAILURE. Otherwise, return SUCCESS.FAILURE. Otherwise, return SUCCESS.FAILURE.POST,169800812,Bob,Alice,50 means that Bob sent Alice $50 on timestamp 169800812.FAILURE.GET,timestamp,name
GET,2,Alice returns Alice's Stripe account balance on timestamp 2.FAILURE.The function's input will be a list of commands (string array), and the output should be a comma-separated string of all the responses from the commands, in sequential order of the commands received in the input. You can assume that the timestamps and commands will always be properly formatted.
Imagine you are creating the backend for an app called StripePay (the next popular peer to peer payment method) that allows Stripe users to send each other money and transfer money to and from their bank accounts. Stripe users make thousands of transactions every day, so we need functionality that handles balance changes, transactions, and balance reads.
Please read the entire prompt before you start coding. Not all the test cases will pass unless all the constraints are met.
We will implement the core of the backend: users sending money to each other. However, our networks can be a bit unreliable, so sometimes we get transactions out of order; therefore, we must execute each command in chronological order. Additionally, StripePay users send each other money and transfer money to and from their connected bank accounts.
Given a list of commands for an account balance API, you will have to parse each command and return a comma-separated string of the command results in sequential order of the commands received, but they must be executed in chronological order. There can be at most 1 command per second. Some of the supported commands are:
INIT,name,balance,bank_1,bank_2,...,bank_n
POST,timestamp,sender,receiver,amount
FAILURE.FAILURE. Otherwise, return SUCCESS.FAILURE. Otherwise, return SUCCESS.FAILURE.POST,169800812,Bob,Alice,50 means that Bob sent Alice $50 on timestamp 169800812.FAILURE.GET,timestamp,name
GET,2,Alice returns Alice's Stripe account balance on timestamp 2.FAILURE.The function's input will be a list of commands (string array), and the output should be a comma-separated string of all the responses from the commands, in sequential order of the commands received in the input. You can assume that the timestamps and commands will always be properly formatted.
Output