今天下午刚刚通过的 IBM OA ,平台是 HackerRank。整体体验下来,难度比我前几天做的亚麻要简单一些,给了一小时的时间,其实绰绰有余,我 18 分钟就全做完提交了,一次过。下面就简单分享下题目和思路。
Question 1: High Load Timestamps
题目要求
Find all the indices i (0-based) of the timestamps such that the ithi^{\text{th}}ith timestamp is greater than twice the average server load.
The functiongetHighLoadTimestampswill take one input:int load[n]:server loads at timestamps
The function should return an array of integers denoting the indices of the timestamps, in increasing order, whereload[i] > 2 × average. If none, return an empty array.
Example
n = 3
load = [1, 2, 9]
average = (1+2+9)/3 = 4
2 × average = 8
Only load[2] = 9 > 8
Answer = [2]
Constraints
思路
直接先算总和,再求平均,最后遍历数组判断 load[i] > 2 × average 的下标即可,复杂度 O(n),秒杀。
Question 2: Minimum Reassignments for Connectivity
题目要求
You are managing
link_nodesdistributed code repositories. Some repositories are already in sync via direct version links. A repository is considered synced with another if theyare directly or indirectly connected.You can perform the reassignment of existing links any number of times (possibly zero):
- Remove one existing link and use it to connect any other pair of repositories.
Implement a function that determines the minimum number of reassignments needed to ensure all repositories are part of a single sync system. If it is notpossible to sync all repositories using the available links, return -1.
Function signature
int minReassignments(int link_nodes, int link_from[], int link_to[])
Example
link_nodes = 4
link_edges = 3
link_from = [1, 1, 3]
link_to = [2, 3, 4]
思路
这个题考的是 图连通性:
- 一个连通图至少需要 n−1n – 1n−1 条边。如果边数不足,直接返回 -1。
- 否则我们数一下当前有多少个连通块,用并查集(Union-Find)来维护。
- 想要把所有连通块拼起来,需要的额外边数 = 连通块数量 – 1。因为允许我们“重连”已有边,所以只要总边数足够,就能保证拼成一个连通图。
整体复杂度 O(n α(n)),足够过所有数据。
IBM OA FAQ
Q: IBM OA 的题型难度大吗?
A: 难度不算大,整体偏基础,考察的都是常见算法和图论思路。正常准备过 LeetCode medium 水平题就可以轻松应对。
Q: OA 平台是哪个?
A: 本次是 HackerRank 平台,界面和操作跟常见的 OA 平台差不多。
Q: IBM OA 需要提前刷哪些题?
A: 建议重点准备 数组模拟、前缀和、并查集、图连通性 相关题型。IBM 的 OA 主要是看基础算法能力,不会太花哨。
Q: 一小时两题够用吗?
A: 绝对够用。这次我 18 分钟就写完交卷,剩下时间可以反复检查。
面试/笔试辅助服务
很多同学在准备 OA 和面试的时候都会遇到这些问题:
時間緊張:容易在细节上卡壳,导致超时;
思路卡顿:遇到陌生题目,一下子不知道怎么下手;
环境紧张:实战比刷题更容易出 bug。
我们团队长期提供:
OA 专业代写(HackerRank、CodeSignal、牛客网等全覆盖,保证 100% 通过,不通过不收费);
遠端無痕助攻(实时语音/提示,帮你在关键点避坑);
全程面试陪跑(VO 辅助、模拟面试、思路提醒)。
无论是 IBM、Amazon、Citadel 还是 Two Sigma,我们都有丰富的实战经验,帮你在实战中稳稳通过。