大家一听到 starbucks ,第一反应可能还是咖啡和门店,但其实他们在数字化这块投入非常大,技术团队实力也不容小觑。很多同学会惊讶:星巴克还有技术岗?其实他们的 OA 难度一点都不低。这次我整理了一份真实的 OA 回忆题,里面有 Python 编程和算法题。整体来说难度算是中等偏上,不会特别刁钻,但很考逻辑清晰度。题目设计既能看出你的基础是否扎实,也会逼着你想想有没有更优的写法,拿来练习思维和刷题都挺合适的。
星巴克面试概览
星巴克 OA 一般分为几个部分:
- 编程题(Python/Java/C++ 可选):逻辑性强,考察异常处理和实现能力。
- 算法题:对数组、排序和优化问题的理解。
- 可能会涉及 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
aandbis 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 in sequence 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。