Goldman Sachs online assessment 高盛 20 分鐘穩過分享

915Views

最近真是 OA 密集轟炸模式,一天排好幾場,幾乎沒停過。 昨天剛剛結束一輪 Goldman Sachs online assessment(HackerRank 平臺),整體難度不算誇張,20 分鐘就穩穩做完了,正好來和大家詳細復盤一下,給還在準備的小夥伴一些參考。

這次的題目主要是兩道 Coding,雖然不是那種超難 DP/圖論,但也有一些細節容易掉坑。 分享下思路和注意點。

Goldman Sachs online assessment 高盛 20 分鐘穩過分享

Problem 1: Minimize Machine Usage

Problem Statement:
You are given a set of machines, each with a certain number of usages. The goal is to bring all usage counts down to zero through a series of operations.

  • In one operation, you can select two machines and decrease each of their usage counts by one.
  • You need to determine the minimum number of operations required to make all machines reach zero.

Key Insights:
This problem can be efficiently solved with a greedy strategy:

  • In every step, pair the machine with the highest usage count with the machine that has the lowest usage count, and reduce both.
  • Repeating this ensures that the “heaviest load” is being balanced by the “lightest load,”preventing unnecessary leftover usages.

Special Case Handling:

  • If a machine’s usage count becomes very small, it can quickly be reduced to zero without wasting additional operations.

Implementation Details:

  • The data size is not very large, so simulation with priority queues is feasible.
  • A max heap can be used to always extract the machine with the largest usage count, and a min heap for the smallest one.
  • Each operation decreases both selected values, and the total count of operations is accumulated until all values reach zero.

Answer:
The final result is simply the sum of all operations performed.
This greedy pairing guarantees the minimum number of steps.

Problem 2: Pods and Costs Placement

Problem Statement:
You are given a collection of elements, where each element has two attributes:

  • pod
  • cost

The task is to arrange these elements in an array according to the following rules:

  1. Elements with a higher cost must be placed with higher priority.
  2. After placing high-cost elements, the lower-cost elements should be assigned to the remaining available positions.

Key Insights:
This is a greedy + data structure problem.

  • First, treat each element as a pair (pod, cost).
  • Sort all elements in descending order of cost.
  • Traverse the sorted list:
    • If the position of a high-cost element is available, it should be fixed there.
    • For lower-cost elements, if the intended position is already occupied, they must move to the next available free slot.

Optimization:
Naively scanning linearly for the next free position is inefficient. Instead:

  • Use a map or disjoint set union (DSU/union-find) to keep track of the “next available position.”
  • This allows jumping directly to the nearest empty slot without checking one by one.

Implementation Strategy:

  1. Sort by cost (descending).
  2. Insert elements in order, fixing high-cost ones first.
  3. Maintain the next available slot pointer using DSU or a map for efficient placement of remaining elements.

Takeaway:
The problem combines greedy prioritization (cost ordering) with efficient data structure usage (map/DSU) to handle placement in logarithmic or near-constant time.

Goldman Sachs online assessment 整體難度與感受

說實話,這次 Goldman Sachs OA 算是比較友好的,不像有些公司的 OA 愛考花哨的概率題或者 tricky DP。 這裡的兩道題邏輯都比較直觀,難點主要在實現細節。

我用時大概 20 分鐘,主要時間花在 debug 邊界條件。 比如:

Problem 1 里,機器次數為 0 的處理是否及時跳出迴圈。

Problem 2 里,空位分配如果寫得不夠嚴謹,可能會覆蓋到已經放好的高 cost 元素。

这类细节一旦没踩稳,很容易浪费十几分钟 debug。

給準備高盛 OA 的小建議

  1. 刷題方向:貪心、排序、map/heap 這種數據結構類的題要重點複習。
  2. 節奏把握:Goldman Sachs 的 OA 時間並不算很緊張,但如果在細節上卡住,就會很危險。
  3. 實戰演練:盡量類比真實環境,定時做題,把“卡點思維”提前練熟。

很多同學其實題目會做,但在實戰裡容易慌張,比如:

不知道什麼時候該果斷放棄 brute force。

debug 時陷入死迴圈,時間就被吃光。

没有规划好写代码的节奏,导致本来 15 分钟能写完的题,拖到 30 分钟还没过样例。

想衝擊大廠但時間有限?

別擔心,我們能為你提供全方位的支援:

OA 代寫 & 筆試包過:HackerRank、牛客網、CodeSignal 等平臺全覆蓋,專業寫手在線代寫,保證所有測試用例 100% 通過,不通過不收費,遠端無痕操作安全可靠。

面試助攻 & VO 輔助:實時語音提示 + 思路引導,讓你在面試中從容應對,北美 CS 專家人工助攻,遠超單純刷題效果。

代面試(全程代面):轉接攝像頭+變聲技術,團隊默契配合,提前多輪類比,幫你輕鬆化身“無懈可擊的候選人”,直通大廠 Offer。

全套護航 & Offer 保拿:從 OA 到技術面,再到簽約談判,全流程一站式服務,預付少量定金,Offer 到手再付尾款,風險極低。

更多支援:模擬面試、面經分享、程式設計代寫、簡歷優化、演算法輔導、Quant 面試輔助,甚至留學生入學代面,我們都能提供專業支援。

如果你也在備戰大廠,不要一個人硬扛。 找對幫手,少走彎路,拿 Offer 真的可以更快更穩!

author avatar
Jory Wang Amazon資深軟體開發工程師
Amazon 資深工程師,專注 基礎設施核心系統研發,在系統可擴充套件性、可靠性及成本最佳化方面具備豐富實戰經驗。 目前聚焦 FAANG SDE 面試輔導,一年內助力 30+ 位候選人成功斬獲 L5 / L6 Offer。
END