
Optiver oa 25 ng , HackerRank two questions: LeetCode style, difficulty Medium, although similar questions, but no ready answer; one of the questions focus on object-oriented design, the question stem is long, need to be patient to read carefully.
Programming Knowledge Quiz (20min) 20 multiple choice questions covering data structures, system design, operating systems, etc., not an easy task.
Optiver Zap-N Games (60min)Nine mini-games ranging from 2 to 15 minutes in length, recommended for mouse operation. Includes: Balloon Challenge, Code Comparison, Grill Master, and Number Cube.
Optiver Online Assessments 1 HackerRank test + more Here is a detailed breakdown.
- HackerRank Code:
- Code 1: LeetCode style questions in the medium to easy range. However, only that types of problem but solutions are not present worldwide.
- Code 2: Object-Oriented Design (OOD) Problem Statement: It is a longish problem statement and one needs to read it carefully.
- Programming Knowledge Test:
- Duration: 20 minutes.
- About 20 multiple-choice questions.
- Topics like data structures, system design and operating systems.
- Optiver Zap-N Game:
- Duration: 60 minutes
- 9 mini-games (Between 2-15 mins each), If you can, use a mouse for these games.
- Balloon challenge, code comparison and number blocks were the games they had.
Optiver OA 1
The requirement is to build a logging server to handle a large number of log messages. Each message contains a unique integer log ID and an integer timestamp. Our server, due to storage limitations, can only return up to m recent logs within an hour on incoming requests.
Three methods need to be implemented:
recordLog(logId, timestamp)
: Logs the log according to the log Id.getLogs()
: The list of integers returned should contain up to m log IDs from the previous hour, listed in ascending timestamp order. If the timestamps are the same, the order is the order in which they were logged to the log server.getLogCount()
: Returns the total number of logs in the last hour.
Sample Input100
10
RECORD 1 0
RECORD 2 300
COUNT
RECORD 3 1200
RECORD 1 1800
GET_LOGS
COUNT
RECORD 4 3900
GET_LOGS
Sample Output1,2
1,2,3,1
4
class LogServer.
def __init__(self, m).
self.logs_dict = {} # Store log IDs and their timestamps.
self.m = m # Limit the maximum number of logs.
self.log_ids_queue = [] # Queue holding the last m log IDs
def recordLog(self, logId, timestamp).
# Update the timestamp of a log ID
if logId in self.logs_dict:
self.logs_dict[logId].append(timestamp)
else: self.logs_dict[logId].append(timestamp)
self.logs_dict[logId] = [timestamp]
# Update the log ID queue
while len(self.log_ids_queue) >= self.m:
oldest_log_id = self.log_ids_queue.pop(0)
del self.logs_dict[oldest_log_id]
self.log_ids_queue.append(logId)
def getLogs(self).
# Return the latest m log IDs in the last hour
current_time = time.time()
one_hour_ago = current_time - 3600
sorted_logs = sorted(
self.logs_dict.items(),
key=lambda x: (x[1][-1], self.logs_dict[x[0]][-1])
)
recent_logs = [
logId for logId, timestamps in sorted_logs
if timestamps[-1] > one_hour_ago
]
return ",".join(str(logId) for logId in recent_logs[:self.m])
def getLogCount(self).
# return the total number of logs in the last hour
current_time = time.time()
one_hour_ago = current_time - 3600
return sum(
len(timestamps)
for logId, timestamps in self.logs_dict.items()
if timestamps[-1] > one_hour_ago
)
Optiver OA 2
Given a list of processes, each process has a unique PID (process identifier), start time and end time. There is also a set of dependencies between the processes. The scheduler can only schedule the start or end of processes on integer time units, such as 1, 2, 1000, 999999, etc., not non-integer values such as 1.5, 700.1, etc.
The task is to implement a Scheduler class containing a constructor and a PrintSchedule method. The constructor accepts a list of processes and dependencies, and the PrintSchedule method takes no arguments.
Sample Input:1 2 100 2100 110 2200 200 2330 1 2 2 2
Sample output:1 100 110 200 2100 2200 2330
Thoughts:
To solve this problem, we can use topological sorting. First, we need to calculate the latest start time for each process, i.e., it must start after all its dependencies have completed. Then, we can use topological sorting to determine the correct order in which processes should be executed. Finally, we will just find the maximum duration that satisfies all the constraints.
import heapq
class Scheduler.
def __init__(self, processes, dependencies): self.processes = {pid: (start, end) for pid, start, _ in processes}.
self.processes = {pid: (start, end) for pid, start, _ in processes}
self.dependencies = dependencies
self.in_degrees = {
pid: 0 for pid in range(1, max(self.processes.keys())+1)
}
for dep in dependencies: self.in_degrees
self.in_degrees[dep[1]] += 1
self.schedule = []
def PrintSchedule(self):
self.topological_sort()
earliest_start = min(p[0] for p in self.processes.values())
latest_end = max(p[1] for p in self.processes.values())
duration = latest_end - earliest_start
print(*sorted(pid for pid in self.schedule), sep=" ")
def topological_sort(self).
queue = []
for pid, (_, end) in self.processes.items():
if self.in_degrees[pid] == 0.
heapq.heappush(queue, (-end, pid))
while queue.
_, pid = heapq.heappop(queue)
self.schedule.append(pid)
for dependent in self.dependencies.get(pid, []): self.in_degrees[pid, []).
self.in_degrees[dependent] -= 1
if self.in_degrees[dependent] == 0:: heapq.heappush()
heapq.heappush(
queue, (-self.processes[dependent][1], dependent)
)
@staticmethod
def read_input().
n_p, n_d = map(int, input().split())
processes = [tuple(map(int, input().split())) for _ in range(n_p)]
dependencies = [tuple(map(int, input().split())) for _ in range(n_d)]
return processes, dependencies
def run_all_test_cases(self): t = int(input(n_p))
t = int(input())
for _ in range(t): processes, dependencies = self.
processes, dependencies = self.read_input()
Scheduler(processes, dependencies).PrintSchedule()
if __name__ == "__main__".
Scheduler([], []).run_all_test_cases()
Recruiter Interview:
- Education background confirmation. sponsorship.
- Why this position, why quantitative trading?
- Why Optiver?
- Do you have something that you have been sticking to for years?
- Can you tell me a period (from your internships) that you receive bad remarks?
- What are their potential competing candidates and other companies that they should pay attention to?
- What are the key factors you pay attention to when choosing companies?
- Which office prefer?
Learn More
Optiver OA Leetcode-Senior Software Engineer
Glassdoor: Optiver OA Question
Optiver Intern OA summer 24 Reddit
Conclusion
After our strong interview assistance, candidates through the analysis of these interview questions and communication, the interviewer not only understands the candidate's programming ability, but also sees my clear thinking and effective communication skills in the problem solving process. These not only help to deal with Optiver's interviews, but also improve our ability to solve real programming problems. I wish you all good luck in your interviews!
Through our strong interview assistanceThese help in Optiver interviews and enhance practical problem-solving ability. These help in Optiver interviews and enhance practical problem-solving ability. Wishing everyone a smooth interview! Wishing everyone a smooth interview !
If you also need our interview coaching services, please Contact Us Now.