OA VO support

Optiver OA – 一亩三分地 – OA 代写 – 面试代面 – VO support

Question 1: Log Server

Problem Statement

You are tasked with building a log server to handle a large number of logs. Each log consists of a logId and a timestamp. Due to storage constraints, the server can only keep logs received in the past hour and store up to m logs.

You need to implement the following functions:

  1. recordLog(logId, timestamp):
    • Records a log entry with a given logId and timestamp.
    • Logs may arrive out of order.
    • Duplicate logIds are allowed.
  2. getLogs():
    • Returns the logIds of all logs received in the past hour in order of their timestamp.
  3. getLogCount():
    • Returns the number of logs received in the past hour.

Constraints

  • 1 ≤ m ≤ 1000
  • 1 ≤ q ≤ 1,000,000
  • timestamp: integer representing seconds.

Input Format for Custom Testing

Sample Input

100
10
RECORD 1 0
RECORD 2 300
GET_LOGS
COUNT
RECORD 3 1200
RECORD 1 1800
GET_LOGS
GET_LOG_COUNT

Sample Output

1, 2
2
1, 2, 3, 1
4

Explanation:

  1. RECORD 1 0: Log with logId 1 is recorded at timestamp 0.
  2. RECORD 2 300: Log with logId 2 is recorded at timestamp 300.
  3. GET_LOGS: Returns the logIds [1, 2] in order of their timestamps.
  4. COUNT: Returns the count of logs received in the past hour, which is 2.
  5. RECORD 3 1200: Log with logId 3 is recorded at timestamp 1200.
  6. RECORD 1 1800: Another log with logId 1 is recorded at timestamp 1800.
  7. GET_LOGS: Returns [1, 2, 3, 1] (logs recorded within the past hour).
  8. GET_LOG_COUNT: Returns 4 (total logs recorded in the past hour).

Question 2: Lion Competition

Problem Statement

As a lion trainer, you are participating in an international lion exhibition. Lions enter and exit the showroom at specific times, and judges tend to award the largest lions the highest scores. You want to estimate your chances of winning by identifying the largest lions present in the showroom at any given time.

You need to implement the following:

  1. LionCompetition constructor:
    • Takes lions (list of lion descriptions) and schedule (list of schedules for entry and exit times).
  2. lionEntered(currentTime, height):
    • Called when a lion enters the room at currentTime with a specific height.
  3. lionLeft(currentTime, height):
    • Called when a lion exits the room at currentTime with a specific height.
  4. getBiggestLions():
    • Returns a sorted list of lions in the room with heights greater than or equal to the largest competing lion.

Constraints

  • Lion names are unique.
  • Times are integers.
  • Lions follow a strictly defined schedule for entry and exit.

Input Format for Custom Testing

Sample Input

definition marry 300
definition rob 250
schedule marry 10 15
schedule rob 13 20
start
8 enter 200
10 enter 310
10 enter 300
11 inspect
13 enter 250
13 inspect
15 exit 300
16 inspect
20 exit 250
21 end

Sample Output

2 marry rob
1 rob

Explanation:

  1. At time 10, two lions (marry and rob) enter with heights 310 and 300, respectively. Both are considered the largest at this point.
  2. At time 13, another lion enters with height 250. Now, only rob is the largest at this time.

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 *