Starbucks Online Assessment 經驗分享|真題+思路解析

986Views

大家一听到 starbucks ,第一反應可能還是咖啡和門店,但其實他們在數位化這塊投入非常大,技術團隊實力也不容小覷。 很多同學會驚訝:星巴克還有技術崗? 其實他們的 OA 難度一點都不低。 這次我整理了一份真實的 OA 回憶題,裡面有 Python 程式設計和演算法題。 整體來說難度算是中等偏上,不會特別刁鑽,但很考邏輯清晰度。 題目設計既能看出你的基礎是否紮實,也會逼著你想想有沒有更優的寫法,拿來練習思維和刷題都挺合適的。

Starbucks Online Assessment 經驗分享|真題+思路解析

星巴克面試概覽

星巴克 OA 一般分為幾個部分:

  1. 程式設計題(Python/Java/C++ 可選):邏輯性強,考察異常處理和實現能力。
  2. 演算法題:對陣列、排序和優化問題的理解。
  3. 可能會涉及 SQL 或邏輯推理題:不同批次不完全相同。

題量不算特別多,但時間比較緊,容錯率不高。

星巴克 Online Assessment 真題回憶

1. Python: Return or Raise ValueError

Implement a function multiply that takes 3 integer arguments: a, b, and bound.

  • If the result of multiplying a and b is less than or equal to bound, return the result.
  • Otherwise, raise a ValueError exception with the message:
    "multiplication of a and b with bound X not possible".

Constraints

  • 1 ≤ queries ≤ 1000
  • 1 ≤ a, b ≤ bound ≤ 10⁵

Sample Input

3
5 2 23
5 2 10
5 2 9

Sample Output

10
10
multiplication of 5 and 2 with bound 9 not possible

2. Element Swapping

You are given an array arr of n integers. You may repeatedly choose an index i (0 ≤ i < n-1) and swap arr[i] with arr[i+1].
Constraint: Each element can be swapped at most once.

The strength of an index i is defined as (arr[i] * (i+1)).
Find the maximum possible sum of strengths of all indices after optimal swaps.

Example

n = 4
arr = [2, 1, 4, 3]

Optimal swaps: swap arr[0] & arr[1], swap arr[2] & arr[3].
Final array = [1, 2, 3, 4].
Sum = (11 + 22 + 33 + 44) = 30.

Sample Input

5
1
9
7
3
2

Sample Output

66

3.Coffee Orders Optimization

Problem Statement:
Starbucks wants to analyze its customers’ coffee ordering patterns. You are given an array of strings representing the drinks ordered insequence during a day. Write a function to find the length of the longest subsequence where the same drink is ordered consecutively.

Example:

Input: ["Latte", "Latte", "Espresso", "Cappuccino", "Cappuccino", "Cappuccino", "Latte"]
Output: 3
Explanation: "Cappuccino" is ordered 3 times in a row, which is the longest streak.

Function Signature:

def longestDrinkStreak(orders: List[str]) -> int:

Constraints:

  • 1 ≤ len(orders) ≤ 10^5
  • Each string in orders consists of English letters only.

整體來看,星巴克的 OA 不僅僅是基礎題,它更注重代碼規範、異常處理和優化思路。 很多同學明明刷過題,但因為沒掌握細節(比如異常資訊格式、交換約束條件),最後結果差一點點。

Programhelp 助你輕鬆拿下 OA

如果你正准备星巴克、IBM、Verisk 这些公司的 OA,其实完全没必要一个人死磕。Programhelp 可以提供遠端語音提醒、debug 指導和題解演練,讓你在有限的答題時間里少走彎路,大幅提高通過率。 很多同學反饋說,遇到卡點時只要有人及時點撥一下,思路立馬就通了,最終順利拿下 OA。

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