Instacart OA 偏業務場景化,題目不卷奇技淫巧,更看重代碼可讀性、邊界處理、以及在電商/配送語境下的建模能力。 我這次做完的直觀感受:難度中等,但細節很多; 誰能更快把業務規則翻譯成數據結構,誰就能搶時間。
流程概覽
- 平臺/時長:常見平臺,約 75–90 分鐘
- 題量:2–3 道 Coding(有時帶 1–2 道 SQL/數據處理小題)
- 語言:P ython/Java/C++ 任意
- 側重點:字串/哈希/排序/堆,外加少量區間或貪心,貼近電商定價、訂單、庫存、分批配送等場景
- 評分習慣:正確性 > 複雜度 > 代碼風格/測試覆蓋
Instacart OA 真題示例
1) Cart Price with Coupons & Taxes
Prompt:
You are given a shopping cart: a list of items with price and quantity. You also receive a set of coupons and a tax rule.
- Each percentage coupon applies to a specific
category(e.g., “produce 10% off”) and can stack with other coupons but cannot make item price below 0. - Each fixed coupon applies to the whole cart (e.g., “$5 off total”) and is applied after percentage coupons.
- Tax is applied to the final total (after coupons).
Return the final payable amount rounded to 2 decimals.
Example:
items = [
{"sku": "A1", "category": "produce", "price": 4.00, "qty": 3},
{"sku": "B2", "category": "dairy", "price": 5.50, "qty": 1}
]
percent_coupons = [{"category":"produce", "off":10}] # 10% off produce
fixed_coupons = [{"off":5}] # $5 off cart
tax_rate = 8.5 # percent
Output: 9.41
Key points: category grouping → apply stacked percentage discounts per line → sum → subtract fixed coupons (clamp at ≥ 0) → apply tax → round.
2) Top-K Frequently Ordered Products (with tie-break)
Prompt:
Given an order history as a list of product IDs, return the top K most frequently ordered products.
- Sort by frequency (desc), then by product ID (asc) on ties.
- If fewer than K distinct products, return all.
Example:
orders = [101,101,20,20,20,7,7,7,7,5]
k = 3
Output: [7, 20, 101]
Key points: Counter/HashMap + min-heap of size K, or sort by (-freq, id). Watch large input (up to 1e5).
3) Batch Delivery Scheduling (Greedy Merge Intervals)
Prompt:
You receive N delivery windows [start, end] (minutes). A driver can deliver multiple orders in one batch if their windows overlap.
Return the minimum number of batches needed to satisfy all windows.
Example:
windows = [[10,20],[15,25],[27,35],[30,34]]
Output: 2
# Batches could be: [[10,20],[15,25]] and [[27,35],[30,34]]
Key points: Sort by start; greedily track current batch’s max-end; overlap → merge 進同一批; 不重疊 → 新批次。 等價於“最少資源數 = 合並非重疊段的計數”。
4) Inventory Refill Simulator (Optional)
Prompt:
Maintain stock levels for SKUs with operations:
add(sku, qty)increases stock.order(sku, qty)tries to fulfill; if insufficient, fulfill what you can and return backorder amount.top_m_lowest(m)returns the SKUs with lowest stock (ascending by qty, then lexicographically).
Key points: HashMap for stock + heap or ordered structure for top_m_lowest。 注意併發/一致性在 OA 不要求,重心在 API 語義與排序。
FAQ
Q:Instacart OA 偏业务,会不会很难?
A:不偏難,核心是把業務規則“程式化”。 數據結構選得對、流程順,分就穩。
Q:需要準備哪些題型?
A:哈希/排序/堆、區間合併、基礎貪心,偶爾字串清洗或小 SQL。
Q:金額精度怎麼處理最穩?
A:首選整數分或 Decimal。 中途不要反覆浮點運算,最後一步再格式化輸出。
Q:邊界怎麼測?
A:空輸入、極值、相同頻次/相同大小的並列排序、折扣疊加后接近 0 的場景、視窗端點貼邊。
還在為秋招煩惱嗎
ProgramHelp 團隊由 7 位畢業於牛津大學、普林斯頓大學、北京大學等頂尖院校的工程師組成,成員曾在 Amazon、Google、阿裡等一線大廠工作。 我們專注於為計算機相關專業的學生和求職者提供高品質的學習輔導與面試訓練。
從演算法與數據結構講解、在線評測思路拆解、到模擬面試與求職經驗分享,我們堅持由學長親自對接,保證溝通高效、內容專業、反饋及時。 無論你是準備校園招聘,還是在刷 OA/VO、面試環節遇到瓶頸,我們都能為你提供全方位的支持,説明你提升能力、增強自信,最終走向理想的 Offer。