
Optiver oa 25 ng ,HackerRank两题:LeetCode风格,难度为Medium,虽有相似题型,却无现成解答; 其中一题聚焦面向对象设计,题干冗长,需耐心细读。
编程知识测验(20min)20道多选,涵盖数据结构、系统设计、操作系统等,非易事。
Optiver Zap-N游戏(60min)九个小游戏,时长2至15分钟不等,推荐使用鼠标操作。包含: 气球挑战、代码对比、烧烤大师、数字方块。
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
要求构建一个日志服务器,用于处理大量的日志消息。每条消息包含一个唯一的整数日志 ID 和一个整数时间戳。我们的服务器由于存储限制,只能在传入请求时返回一小时内的最多 m 条最新日志。
需要实现三个方法:
recordLog(logId, timestamp)
:根据日志Id记录日志。getLogs()
:返回的整数列表中应包含前一小时最多的 m 条日志 ID,按时间戳升序列出。如果时间戳相同,则顺序为记录到日志服务器的顺序。getLogCount()
:返回最近一小时内的日志总量。
样例输入100
10
RECORD 1 0
RECORD 2 300
COUNT
RECORD 3 1200
RECORD 1 1800
GET_LOGS
COUNT
RECORD 4 3900
GET_LOGS
样例输出1,2
1,2,3,1
4
class LogServer:
def __init__(self, m):
self.logs_dict = {} # 存储日志ID及其时间戳
self.m = m # 最大日志数量限制
self.log_ids_queue = [] # 保存最近m个日志ID的队列
def recordLog(self, logId, timestamp):
# 更新日志ID的时间戳
if logId in self.logs_dict:
self.logs_dict[logId].append(timestamp)
else:
self.logs_dict[logId] = [timestamp]
# 更新日志ID队列
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):
# 返回最近一小时内的最新m个日志ID
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):
# 返回最近一小时内的日志总数
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
给定一个进程列表,每个进程都有一个唯一的PID(进程标识符)、开始时间和结束时间。此外还有一组进程之间的依赖关系。调度器只能在整数时间单位上安排进程的开始或结束,例如1、2、1000、999999等,而不是1.5、700.1等非整数值。
任务是实现一个Scheduler类,包含构造函数和PrintSchedule方法。构造函数接受进程列表和依赖关系,PrintSchedule方法不带任何参数。
样例输入:1 2 100 2100 110 2200 200 2330 1 2 2 2
样例输出:1 100 110 200 2100 2200 2330
思路:
为了解决这个问题,我们可以使用拓扑排序。首先,我们需要计算每个进程的最晚开始时间,即它必须在其所有依赖项完成之后才能开始。然后,我们可以使用拓扑排序来确定正确的进程执行顺序。最后,我们将找到满足所有约束条件的最大持续时间即可。
import heapq
class Scheduler:
def __init__(self, processes, dependencies):
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[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[dependent] -= 1
if self.in_degrees[dependent] == 0:
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())
for _ in range(t):
processes, dependencies = self.read_input()
Scheduler(processes, dependencies).PrintSchedule()
if __name__ == "__main__":
Scheduler([], []).run_all_test_cases()
Recruiter面试:
- 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? Chicago or Houston?
Learn More
Optiver OA Leetcode–Senior Software Engineer
Glassdoor: Optiver OA Question
Optiver Intern OA summer 24 Reddit
Conclusion
经过我们的强力面试辅助,候选人通过这些面试题的解析和沟通, 面试官不仅了解了候选人的编程能力,也看到了我在解决问题过程中清晰的思路和有效的沟通技巧。 这些不仅有助于应对Optiver的面试,同时也能提升我们解决实际编程问题的能力。祝大家面试顺利!
Through our strong interview assistance, the candidate not only gained an understanding of the candidate’s programming ability, but also demonstrated clear thinking and effective communication skills. These help in Optiver interviews and enhance practical problem-solving ability. Wishing everyone a smooth interview!
如果您也需要我们的面试辅导服务,请 立即联系我们。