1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
qwelly [4]
3 years ago
8

Implement a simplified version of a crypto broker platform. Initially, there is an array of users, with each user depositing onl

y cash - deposits[i] is the amount of cash the (i + 1)th user has deposited.
Assume that for now the platform contains just a single stock and all operations are done with this stock only. All operations are supposed to be in the same currency, and currency exchange is not supported for now.
The platform should support the following 3 types of operations:
"deposit " - deposits money to the specified user account.
"buy " - the specified user buys the specified amount of crypto at the specified price. The platform should make sure the user has enough money in their account to process the operation.
"sell " - the specified user sells the specified amount of crypto at specified price. The platform should make sure the user has enough cryptos in their account to process the operation.
Your task is to return an integer array representing the total amount of money in the specified user's account after each operation.
Example
For deposits = [9, 7, 12] and
operations = [
"buy 1 3 2",
"sell 1 4 10",
"deposit 2 12",
"buy 2 10 2",
"buy 2 6 3"
]
the output should be cryptoTrading(deposits, operations) = [3, 3, 19, 19, 1].
Let's consider all operations:
The user with user_id = 1 wants to buy 3 shares of the stock at price = 2 - the required amount of money is needed_money = 3 * 2 = 6. The user has 9 ≥ 6 units of money in their account, so this operation will be processed successfully. After this operation, the user has 3 units of money remaining.
The user with user_id = 1 wants to sell 4 shares of the stock at price = 10 - this operation will not be processed successfully because the user does not have 4 shares of the stock. Since the operation is not processed successfully, the user still has 3 units of money remaining.
The user with user_id = 2 deposits 12 units of money into their account. After this operation, the user has 19 units of money.
The user with user_id = 2 wants to buy 10 shares the stock at price = 2 - the required amount of money is needed_money = 10 * 2 = 20. The user has 19 < 20 units of money in their account, so this operation will not be processed successfully. The user still has 19 units of money remaining.
The user with user_id = 2 wants to buy 6 shares of the stock at price = 3 - the required amount of money is needed_money = 6 * 3 = 18. The user has 19 ≥ 18units of money, so this operation will be processed successfully. After this operation, the user has 1 unit of money remaining.
So, the output is [3, 3, 19, 19, 1].
Input/Output
[execution time limit] 0.5 seconds (cpp)
[input] array.integer deposits
An array of integers representing the amount of money (in cash) that users deposit to their accounts.
Guaranteed constraints:
1 ≤ deposits.length ≤ 104,
1 ≤ deposits[i] ≤ 105.
[input] array.string operations
An array of strings representing the operations described above. Specifically, it's guaranteed that:
In buy and sell operations - amount and price are integers.
In all operations - user_id will be integers between 1 to deposits.length.
After each operation, the total amount of money in each user's account will be an integer.
Guaranteed constraints:
1 ≤ operations.length ≤ 104.
[output] array.integer
An array of integers where the ith element of the array represents the total amount of money in the specified user's account after the ith operation.
PLEASE DO THIS IS JAVA or C++
vector cryptoTrading(vector deposits, vector operations) {
}
Computers and Technology
1 answer:
Salsk061 [2.6K]3 years ago
3 0
Jriririiekeekekkksks
You might be interested in
The ________ multiple-selection PHP statement is used to handle decision making and can be used to replace multiple if and if...
Sedaia [141]

Answer:

Option (4) is the correct answer of this question.

Explanation:

The switch is used to handle the multiple selections in the program when we need to choose on the condition and we have more then one condition arises then we have used the switch statement in the PHP.

Syntax of using Switch:-

switch(variable)  

{

case 1. statement

Break;

..................

default :

case n:

statement n

}

Other options do not use multiple selections so they are incorrect options.

7 0
2 years ago
Different between internet and email​
pentagon [3]

Answer:

The internet allows you to connect with people and information around the world. The internet is more broad and could include searching things up or message-based websites. Emails is more specific, with it being when you send someone a message (called an email) on a mail website (that allows you to get messages from other people, websites, etc.)

Explanation:

In my answer.

5 0
3 years ago
A communications medium that carries a large amount of data at a fast speed is called
babymother [125]
Either Firewire, or an ethernet cable.
7 0
3 years ago
February 1995, Kevin Mitnick was arrested. While on parole was he allowed to have a phone or computer?
m_a_m_a [10]

Answer:

He was not allowed on a phone of computer after being arrested.

Explanation:

If you read about it he wasn't even allowed to work at 7-11 because of an electronic cash register.

6 0
3 years ago
Read 2 more answers
What does it mean by MYRIAD of data?
pentagon [3]

Answer:

The term Myriad means an indefinitely large number of things. And when we say Myriad of data, we mean an indefinitely large amount of data like in Petabytes.

Explanation:

What it does implies is that you are dealing with a large amount of data. And hence we are dealing with something like bigData. And hence, technologies related to BigData are going to operate. And this term is used as a noun as well as an adjective when we talk about English. And hence, you can use it with "a" or without the "a" as well. It has been a part of reputable English and has been repeatedly used by top authors like Milton.

5 0
3 years ago
Other questions:
  • Your computer has gradually slowed down. What's the most likely reason?
    8·1 answer
  • So how do I repost a answer that I already answered to a question because I answered this question but later it told me to repos
    14·1 answer
  • Write a loop that continually asks the user what pets the user has, until the user enters "rock", in which case the loop ends. I
    12·1 answer
  • Secure Wi-Fi networks and VPNs use _____ to secure data transferred over a network.
    13·1 answer
  • Which option nukes your systemâall apps, programs, user files, user settingsâand presents a fresh installation of Windows?
    13·1 answer
  • package dataStructures; /** * Class OrderedLinkedList. * * This class functions as a linked list, but ensures items are stored i
    8·1 answer
  • What are 25 items that trees made?
    6·2 answers
  • The blue section of the following Venn diagram could represent which of the following Boolean statements?
    14·1 answer
  • Which of the following are drivers of machine learning growth?
    15·1 answer
  • a data analyst is working with a spreadsheet that has very long text strings. rather than counting the characters themselves to
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!