今天下午剛剛通過的 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,我們都有豐富的實戰經驗,幫你在實戰中穩穩透過。