Google 2026 Intern 的 OA 終於在 8 月底開了,相比其他大廠算是比較晚的。 今年題型延續了以往風格,依舊是邏輯清晰、考察思維的演算法題。 我這邊整理兩道以前做過的 OA 題,題意和思路都挺有代表性,給大家一個參考。
Google Online Assessment 面試概覽
- 平臺:部分批次在 Codility,部分批次在 HackerRank
- 時長:75 分鐘左右
- 題量:2 道演算法題(陣列/前置後綴/數學思維)
- 難度感受:整體中等,題面不長,但需要抓住核心思路才容易做對
- 考察點:
- 陣列與數學推導結合
- 前綴最大 / 後綴最小的處理思路
- 時間複雜度要求 O(n) 或 O(n log n),暴力會超時
- 建議:一定要提前熟悉 Google OA 的套路題,重在「發現規律 → 轉換問題」
真題回顧
Question 1: Minimize Absolute Sum After One Change
Given an integer array, you may flip at most one element (multiply it by -1).
Find the minimum possible absolute value of the array sum after the change.
Example
Input: [2, -3, 5]
Output: 0
Explanation: Original sum = 4. Flipping 5 → sum = -1, abs = 1. Flipping 2 → sum = 0. So the best result is 0.
思路解析
- 先算出原陣列總和
s。 - 如果翻轉一個元素
a[i],總和變為s - 2*a[i]。 - 遍曆每個元素,取
min(abs(s - 2*a[i]))。 - 最后和
abs(s)比較,答案就是二者的最小值。
這裡的關鍵就是把「乘 -1」轉化為「總和變化 -2*a[i]」。 實現上只要一次遍歷即可,複雜度 O(n)。
Question 2: Count Sorted Split Ways
You are given an array. You want to split it into two non-empty parts: left and right.
Then sort each part in non-decreasing order, and concatenate them.
Return the number of ways to split the array so that the final concatenated array is sorted.
Example
Input: [2, 1, 3, 5]
Output: 2
Explanation:
- Split at index 1 → left
[2], right[1,3,5]→[2,1,3,5]not sorted. - Split at index 2 →
[2,1] | [3,5]→[1,2,3,5]sorted ✅. - Split at index 3 →
[2,1,3] | [5]→[1,2,3,5]sorted ✅.
思路解析
- 排序后,左段的最大值是
max(left),右段的最小值是min(right)。 - 拼接后是否有序,只要滿足
max(left) <= min(right)即可。 - 因此遍歷每個切分點,判斷條件成立與否。
- 實現上可以先預處理:
prefix_max[i]表示前 i 個元素的最大值suffix_min[i]表示從 i 到末尾的最小值
- 最後統計滿足
prefix_max[i] <= suffix_min[i+1]的分割點數量即可,複雜度 O(n)。
這道題表面上是「類比排序」,其實是「前綴/後綴資訊」的經典套路。
Google Online Assessment 小结
這兩道 OA 題風格很典型:題面看似簡單,核心在於能不能快速發現數學規律或前後綴關係。 第一題是「數值翻轉的等價轉化」,第二題是「陣列拼接的最大最小邊界條件」。 只要思路清晰,代碼實現並不難。
Offer之路不在孤单
很多同學做 Google OA 時,都會遇到「思路卡住 → 時間被拖走」的情況。 Programhelp 提供 無痕連線助攻:
- 實時語音提醒,幫你卡點轉思路,不會陷在 brute force 裡出不來;
- 遠端連線輔助,保證代碼實現高效無誤;
- 提前演練 Google 高頻 OA 題庫,類比實戰環境。
別再一個人死撐,有 Programhelp 在,OA 也能輕鬆拿下 ✅ 。