最近刷完了一輪 Bytedance Online Assessment ,在 CodeSignal 平臺完成了全套 4 題,時間大約 70 分鐘。題目難度不算特別高,但考察邏輯、觀察力和編碼細節,完全是典型的題庫抽題風格,和 Visa / Capital One / HRT / SIG 很像。整體來說,30 分鐘內搞定是完全可能的,但如果粗心或者沒有抓住題目特點,很容易卡在邊界條件上。下面分享每道題的感受和解題思路。

Matrix Completion
Problem Description:
The given matrix mat contains only one 4×4 square (based on column segments), so we just find the missing value in it (in the example, it is 11), and replace the “?” with this value.
解析與思路:
- 矩陣寬度是 4 的倍數,每個 4×4 方塊內數字唯一
- 找到
"?"所在的 4×4 方塊 - 收集已出現的數字,透過
1..16與已有數字的差集得到缺失值 - 將
"?"替換
小技巧:
- 字串先轉換為整數,方便集合運算
- 即使列數很大,只處理方塊也能保持高效
Molecular Bond Balancing
Problem Description:
You are a chemist working in a laboratory that studies molecular compounds. You have two arrays representing the atomic weights of elements in two different compounds: x represents the primary elements and y represents the secondary elements. Your research has shown that when two compounds have the same “balance factor” (calculated as the difference between primary and secondary atomic weights), they can potentially form stable molecular bonds. Count the total number of valid molecular pairings (i, j) where i ≤ j and the balance factors are equal: x[i] – y[j] = x[j] – y[i].
解析與思路:
- 核心公式可化簡為
x[i] + y[i] = x[j] + y[j] - 遍歷陣列,計算每個元素的和
x[i]+y[i] - 用雜湊表統計每個和出現的次數
- 對頻率為 k 的值,組合數為
k*(k-1)/2 - 累加得到總配對數
小技巧:
- 避免暴力列舉
(i,j),複雜度 O(n²) 會超時 - 雜湊統計讓複雜度降到 O(n)
Consonant Substitution Cipher
Problem Description:
You’re implementing a simple substitution cipher that only affects consonant characters in a memo. This cipher works by shifting every k-th consonant to the following consonant in the alphabet, while leaving vowels and other characters unchanged.
解析與思路:
- 遍歷字串,維護一個子音計數器
- 每遇到第 k 個子音,替換為下一個子音
- 注意大小寫和 z -> b 的迴圈
- 其他字元保持不變
小技巧:
- 建議預定義子音順序表,查詢替換更方便
- 子音計數要精準,容易出錯的點是 wrap-around 和大小寫
Monotonic Triplets
Problem Description :
You are given an array of integers arr. Determine whether each sequence of three elements in the array (arr[i], arr[i+1], arr[i+2]) are monotonic.
解析與思路:
- 滑動視窗取每三個連續元素
- 判斷嚴格遞增
arr[i] < arr[i+1] < arr[i+2]或嚴格遞減arr[i] > arr[i+1] > arr[i+2] - 滿足條件返回 1,否則 0
小技巧:
- 注意等號,必須嚴格單調
- 複雜度 O(n) 完全夠用
不要讓繁瑣的 OA 成為你進入位元組跳動的絆腳石。
很多同學在實戰中容易卡殼。如果你希望在 30 分鐘內精準破題,拿下大廠面試入場券,ProgramHelp 專業服務 現已全面升級:
- 實時面試輔助:針對 CodeSignal 平臺特性,提供高效、精準的解題思路與程式碼實現,助你滿分通關。
- 全真題庫覆蓋:深度解析類似 Visa、Capital One、HRT 等名企的高頻抽題風格,讓你對每道題都“似曾相識”。
- 極致編碼細節:從複雜的字串處理到嚴苛的時間複雜度最佳化,我們幫你規避所有潛在的邊界陷阱。
選擇 ProgramHelp,讓你的 Offer 更有保障!