Robinhood APM Program Pre-Screen – Robinhood OA – 一亩三分地 – OA 代写 – 面试代面

Question 1: Warrior vs Monster

You and your alliance of warriors are trying to kill a monster to score points in a Kingdom vs. Kingdom (KvK) event. Each unit (both a warrior and a monster are considered a unit) has a certain number of health points (healthPoints) and attack damage value (attackDamage). When one unit attacks another, the health of the unit that is under attack is decreased by the attacker's damage value. If a unit's health points are reduced to zero or less, the unit dies and can't take part in the battle anymore.

The skirmish between the warrior alliance and the monster proceeds in the following way:

  • Each turn, you direct one of your warriors to attack the monster.
  • If the monster dies, you win.
  • If the monster is still alive after an attack, it counter-attacks the same warrior who attacked it in the previous step.
  • If all of your warriors die, you lose.

Find the maximum number of your warriors that will remain after defeating the monster. If it's impossible to kill the monster without losing all your warriors, return 0.

Example

Input:

healthPoints = [110, 30, 50]
attackDamage = [12, 11, 20]

Output:

2

Explanation: One of the optimal strategies is:

  1. Attack the monster four times with the second warrior. The monster's health will become 110 - 20 * 4 = 30, while the warrior's health will be 50 - 12 * 4 = 2.
  2. If you use the second warrior again immediately, it will die. Instead, use the first warrior instead. Its three attacks will deplete the monster's health by 11 * 3 = 33 points, while the monster will respond only twice. After the third attack, it will die instantly.
  3. In this way, you are able to save both of your warriors and win the battle.

Question 2: Bank System

You've been asked to program a bot for a popular bank that will automate the management of incoming requests. Every request has its own timestamp in seconds, and it is guaranteed that all requests come sequentially, i.e., the timestamp is strictly increasing. There are two types of incoming requests:

  • deposit <timestamp> <holder_id> <amount> — request to deposit <amount> amount of money in the <holder_id> account.
  • withdraw <timestamp> <holder_id> <amount> — request to withdraw <amount> amount of money from the <holder_id> account. As a bonus, the bank also provides a cashback policy — 2% of the withdrawn amount rounded down to the nearest integer will be returned to the account exactly 24 hours after the request timestamp. If the cashback and deposit/withdrawal happen at the same timestamp, assume cashback happens earlier.

Your system should also handle invalid requests. There are two types of invalid requests:

  1. Invalid account number;
  2. Withdrawal of a larger amount of money than is currently available.

For the given list of initial balances and requests, return the state of balances straight after the last request has been processed, or an array of a single element [-<request_id>] (please note the minus sign), where <request_id> is the 1-based index of the first invalid request. Note that cashback requests which haven't happened before the last request should be ignored.

Example

Input:

balances = [1000, 1500]
requests = ["withdraw 1613327630 2 480",
"withdraw 1613327644 2 800",
"withdraw 1614105244 1 100",
"deposit 1614108844 2 200",
"withdraw 1614108845 2 150"]

Output:

[900, 295]

Explanation: Here are the states of balances after each request:

  1. Initially: [1000, 1500]
  2. "withdraw 1613327630 2 480": [1000, 1020]
  3. "withdraw 1613327644 2 800": [1000, 220]
  4. At 1613414030, the 2nd account will receive cashback of 480 * 0.02 = 9.6, rounded down to 9: [1000, 229]
  5. At 1613414044, the 2nd account will receive cashback of 800 * 0.02 = 16: [1000, 245]
  6. "withdraw 1614105244 1 100": [900, 245]
  7. "deposit 1614108844 2 200": [900, 445]
  8. "withdraw 1614108845 2 150": [900, 295]

The final balances are [900, 295].

CSOAhelp长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。

CSOAhelp consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.

Leave a Reply

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