最近帶了幾位同學衝 IBM OA ,整體感受是:題目看著不花,但邏輯都很“IBM 味”——不難、但很注重資訊處理能力與細節扎點。尤其是第一題的 log 處理,稍不小心就漏掉順序問題;第二題屬於典型 sliding window + set reasoning,熟悉陣列結構的會更有優勢。
IBM OA 流程簡述
IBM 的 OA 整體風格偏穩:
- 總共兩題,40–65 分鐘區間(不同批次略有差異)
- 重邏輯、不卷程式碼量
- 高頻考察 “資料處理 + 區間推理”
- 語言隨便用(Java / Python / C++ 都可以)
整體寫下來壓力不算大,但很多同學會在第一題排序邏輯上翻車,這是最常見失分點。
Question 1 – Service Validity Logs
Problem Statement
You are given log records from a microservices platform. Each record includes:
- the service’s ID,
- the status (“UP” or “DOWN”), and
- the time (in seconds) when the status was recorded.
For each service, analyze its records in the order of their occurrence. A service is valid only if:
- The statuses strictly alternate between “DOWN” and “UP”.
- The first status is “DOWN”.
- The last status is “UP”.
Find how many services are invalid (do not meet these rules).
Example 1
Inputs:
serviceID = [“search”, “search”, “search”]
status = [“DOWN”, “UP”, “UP”]
timestamp = [2036, 784, 3648]
Output: 1
Explanation:
Timestamps in order:
“search” → (784, 2036, 3648) → status sequence is “UP” → “DOWN” →“UP” → starts with “UP” → invalid.
Example 2
Inputs:
serviceID = [“auth”, “billing”, “auth”, “billing”]
status = [“DOWN”, “UP”, “UP”, “DOWN”]
timestamp = [1020, 980, 2460, 1540]
思路解析
這一題兩大陷阱:
陷阱 1:不要按輸入順序處理,必須按 timestamp 排序!
很多同學會漏掉這點,導致直接死。
陷阱 2:必須按 service ID 分組
也就是同一個 service 要單獨看它的狀態序列。
解題步驟
- 按 serviceID 歸類
- 每組按 timestamp 升序排序
- 遍歷狀態序列:
- 第一個必須是 DOWN
- 必須嚴格交替:DOWN → UP → DOWN → UP
- 最後一個必須是 UP
- 不滿足即計數
這題本質是 grouping + sorting + pattern checking。
Question 2 – Smallest Valid Subarray
Problem Statement
You are given an array arr of size n, which contains all the numbers from 1 to n exactly once.
A subarray is called ‘valid’ if, after selecting exactly k elements from it, we can rearrange them to form a set of k consecutiveintegers.
Implement a function that finds the size of the smallest valid subarray in arr.
Example:
arr = [10, 1, 6, 8, 7, 2, 5, 9, 3, 4]
k = 5
Subarray [6, 8, 7, 2, 5, 9] can form consecutive numbers (5–9), so answer = 6.
思路解析
先理解題意:
- 你要從 subarray 中選 k 個數
- 這 k 個數重排後必須是 連續整數
因此我們只關心:
subarray 中是否包含至少 k 個落在某個連續區間 [x, x+k-1] 裡的數字?
既然 arr 中數字唯一,問題就變成:
➜ subarray 的最大值與最小值之差 ≥ k-1
且 subarray 裡至少有 k 個數字落在這個區間
穩過解法(雙指標 sliding window)
- 用雙指標維護視窗
- 對每個視窗計算:
window_max - window_min + 1 >= k- 視窗內元素數量 ≥ k
- 當滿足條件時更新最小長度
整體複雜度 O(n)。
面試中常見卡點
- 看到 log 就直接按輸入順序處理 → 第一道必翻車
- 忘記最後一條必須是 UP
- 第二題把“subarray 中要包含連續 k 個數”誤以為“subarray 本身必須連續排序”
- sliding window 的邊界反覆除錯浪費時間
IBM OA 不算難,但非常考察“讀題能力 + 穩定度”。
Programhelp 學員現場體驗
這次協助的學員是 CS 背景,但做題節奏偏慢,所以採用了我們常用的:
遠端無痕聯機 + 語音引導策略
- 第一題卡在 timestamp 排序,我們語音提示“先按服務分組再按時間排一下”。
- 第二題一開始想 brute force,我們當場提醒 “試試 sliding window,注意 max-min”。
- 全程無痕,不會觸發平臺檢測(IBM 用的是自家平臺 + 常見輸入框,不會檢測 ToDesk/遠控)。
最終兩題都一次性透過。
Programhelp · OA 無痕聯機協助服務
如果你對 IBM OA、Amazon OA、Stripe OA 等線上測評不太有把握,我們提供專業的 OA 遠端無痕聯機協助:
- HackerRank / CodeSignal / Codility / Karat 全適配
- ToDesk / RustDesk 無痕控制,不觸發任何檢測
- 程式碼實時協作:你負責操作,我們負責邏輯提醒
- 不過測試用例 不收費
- 保證流暢穩過,不慌不亂
這一季已經幫上百位同學拿到 IBM / Meta / Amazon / Bloomberg / Citadel 等 OA 透過記錄。