eBay New Grad OA 權威覆盤:資料結構 Hard 題 Building Houses 深度解析

各位準備申請 eBay New Grad 的同學,我們完全理解你們的壓力和焦慮。面對像 eBay 這種頂尖公司的 OA,每一個環節都至關重要,那種“一題定生死”的緊張感是巨大的。

就在最近,我們 ProgramHelp 的精英輔導團隊(由前 Google、Meta 的資深工程師和來自 CMU、Stanford 等名校的校友親自組建)成功陪伴並指導了一位學員。他順利地衝破了第一輪 OA 的重重難關,拿下了含金量極高的 Onsite 面試入場券!下面詳細分享一下~

eBay New Grad OA 流程與高風險點解析

環節 時長/題目數 核心內容 風險等級
邀請函 郵件傳送 通常在簡歷投遞後 1-3 周內發出。
測試平臺 通常使用 CodeSignalHackerRank 需提前熟悉平臺環境,尤其是 CodeSignal 的螢幕錄製和攝像頭監控機制。
演算法程式設計 (Coding) 約 90 – 120 分鐘 / 3-4 道題 題目難度分佈:1 Easy, 1-2 Medium, 1 Hard (如 Building Houses)。 極高
行為/性格測試 (Optional) 約 20 分鐘 考察工作匹配度,通常不影響技術面試。
結果通知 約 1-4 周 只有全部題目 (All Cases) 透過且程式碼效率 (Time Complexity) 達標的候選人才會被邀請進入 Onsite 環節。 核心風險區

Problem 1 — Count Elements with Odd Occurrences of a Digit

Problem Description

You are given an array of non-negative integers numbers.
Your task is to count how many elements in the array contain an odd number of occurrences of the digit '0'.

Constraints

  • 1 ≤ numbers.length ≤ 1e5
  • 0 ≤ numbers[i] ≤ 1e9

Example
numbers = [4, 50, 100, 65, 2000, 700, 1, 10] → answer = 3

Element Count of ‘0’ Odd/Even Result
4 0 even No
50 1 odd Yes
100 2 even No
65 0 even No
2000 3 odd Yes
700 2 even No
1 0 even No
10 1 odd Yes

Total = 3

覆盤 & 難點在哪裡?

這道題本質是簡單的 digit count,但真正容易錯在:

  • 0 本身需要被統計(很多人寫了 str(n).count("0") 但漏測單元素輸入)
  • 存在極端值,例如 1000000000
  • 強調 digit '0',不是“所有 digit”,別寫成泛化版本

實現上最穩妥的方式就是統一轉字串處理。

Problem 2 — Array Reduction

Problem Description

You are given an array of non-negative integers numbers.
Perform the following algorithm repeatedly until all elements become zero:

  1. Find index i of the leftmost non-zero element.
    Let x = numbers[i].
  2. Starting from index i to the end:
    • If numbers[j] < x, stop this step immediately and return to Step 1
    • Else subtract x from numbers[j]
  3. Repeat until all elements become 0.

Return the final state of the array.

Constraints

  • 1 ≤ numbers.length ≤ 1e5
  • 0 ≤ numbers[i] ≤ 1e9

覆盤 & 難點在哪裡?

表面是一個模擬題,但複雜度計算非常“工程思維”:

  • 如果只寫“照著步驟暴力模擬”,很容易 O(n²) 直接超時
  • 關鍵點在於一旦遇到 numbers[j] < x,整個 subtract 流程必須中斷
  • 中斷後回到 Step 1,因此 左端始終保持單調非遞減趨勢

工程上,這種題目最穩定的實現方式是模擬,但要最佳化“不必要的 subtract”,整體邏輯實現要非常嚴謹。

Problem 3 — Building Houses

Problem Description

You are given a list of queries representing locations on an integer line where houses are built one by one.

A house can be built at a location if at least one of its neighboring points is empty.

After each insertion, return the length of the longest contiguous segment of houses.

Constraints

  • 1 ≤ queries.length ≤ 1e5
  • -1e9 ≤ queries[i] ≤ 1e9
  • All query locations are unique
  • All placements are guaranteed valid

Example
queries = [2, 1, 6, 3, 5] → output = [1, 2, 1, 3, 5]

覆盤 & 難點在哪裡?

這是標準的“動態維護連續段”問題,關鍵在於:

  • 位置範圍可達 ±1e9,不能用陣列
  • 查詢順序動態,必須使用 hash + 兩側合併
  • 兩端可能各自屬於不同 segment,需將它們 union 成一個新的更長 segment
  • 每一步都要維護全域性最大連續長度

常見做法:

  • 使用 map / hash 記錄 segment 左右邊界
  • 每次插入時,看左邊 / 右邊是否有房
  • 三種情況:左接、右接、左右都接 → 需要“合併兩段”

資訊更新順序稍微寫錯就會造成錯段、錯邊界、長度錯誤。

ProgramHelp 如何助攻這類 OA?

我們提供的不是廉價的“代寫”,而是高階的技術保險和專業指導。

  • 絕對權威背書: 我們的團隊成員本身就是各大廠的前員工。我們深知面試官的評判標準,清楚什麼樣的程式碼能夠被稱為 “Clean Code”,能夠順利透過自動查重和人工審查。
  • 實時輔助(VO/OA Support): 在 OA 過程中,我們的工程師會透過無延遲的實時螢幕共享/語音輔助,指導你完成所有題目。即便是Hard 題,我們也能在 20 分鐘內,為你梳理出完整的方案,並讓你以專業口吻應對可能的實時監控或後續的 Follow-up 提問。
author avatar
jor jor
END
 0