Amazon SDE-NG Back-to-Back 3轮面试案例分享

Amazon 2025年夏天高强度的发面试中,为了提高效率基本都是3场技术面一起来,全程使用chime平台完成,我们一起来看看最近亚马逊出了什么题目吧。以下来自于我们CSOahelp真实客户的面试记录,CSOahelp面试辅助老师全程提供解题思路、Follow up 以及详细完整代码; 不用刷题轻松进大厂。

第一轮:可扩展定价引擎设计

Problem 1: Amazon Pricing Engine

As part of the Amazon Pricing team, you are tasked with implementing a simple pricing engine that can apply a percentage discount to a product’s base price. For example, 10% off a product priced at $100 should return $90.
Build this with extensibility in mind, as more discount types will be added in the future.

# percentage: e.g. 10% off
# flat: -$5
# conditional: if > 100, then apply a flat/percentage
# combination: flat + percentage + conditional

# dicount strategy? (4)

设计一个定价引擎,支持百分比折扣(如 $100 打 10% 得 $90),并可轻松扩展到固额折扣、条件折扣、组合折扣等。

解题思路

  1. 策略模式(Strategy):抽象出 DiscountStrategy 接口
  2. 具体实现PercentageDiscountFlatDiscountConditionalDiscount 等继承该接口
  3. 组合/装饰者CompositeDiscount 按顺序链式调用多个策略
  4. 封顶策略MaxDiscountCap 在最终结果上应用上限

CSOahelp完整提示示例,候选人无压力照着念,轻松进入coding环节

        
""" 
Step 1: Clarification

Build a pricing engine that:
Applies one or more discounts to a base price
Allows each discount type (percentage / flat / conditional)
 to work independently or be combined
Is easy to extend with future logic


Entity / Class	                 Responsibility
DiscountStrategy (abstract)	   Base interface for any discount logic
PercentageDiscount	           Applies % off a given price
FlatDiscount	               Applies fixed $ off a given price
ConditionalDiscount	           Wraps another discount strategy, only applies if a condition is met
CompositeDiscount	           Applies multiple discounts in sequence
PricingEngine	               Accepts a strategy (or combination) and applies it to a price

Relationships Between Entities
PricingEngine → has-a DiscountStrategy
PercentageDiscount, FlatDiscount, etc. → inherit from DiscountStrategy
ConditionalDiscount → wraps another DiscountStrategy
CompositeDiscount → contains multiple DiscountStrategy objects and applies them in order


"""

""" 
Logic Thoughts:
We'll use Object-Oriented Design to make it extensible:
A base class/interface DiscountStrategy
Subclass PercentageDiscount implements it
Later we can add FixedAmountDiscount, BuyOneGetOne, etc.
Pricing engine applies the strategy
"""

        
    

我们的辅助老师写了超长的代码,最后完整输出答案,候选人抄写了20多分钟,面试官超满意。

第二轮:最短覆盖子数组

Write a program which takes an array of strings and a set of strings, and returns the indices of the starting and ending index of a shortest subarray of the given array that “covers” the set, i.e., contains all strings in the set.

Example:
<apple, banana, apple, apple, dog, cat, apple, dog, banana, apple, cat, dog>
set: <banana, cat>
Smallest subarray starts at 8, ends at 10.

给定字符串数组和目标字符串集合,返回能够覆盖集合中所有元素的最短连续子数组的起止下标。

解题思路

  1. 滑动窗口:用 leftright 双指针维护窗口
  2. 哈希计数found[word] 跟踪窗口内目标词出现次数
  3. 扩 → 收:右指针扩张,窗口包含所有目标后左指针收缩并更新最优解
        
"""
Step 1: Clarification
We are given:

An array of strings.

A set of target strings.

Step 2: Algorithm Logic (Sliding Window + Hash Map)
We want to find the smallest window [left, right] such that all strings
 in target_set appear at least once inside the window.

High-level plan:
Use a sliding window approach: move two pointers left and right.

Maintain a count of target words found inside the current window using a hash map (found).

Expand right to include more words until all target words are found.

Then try to move left to shrink the window while still covering the set.

Keep track of the minimum-length window seen.

"""

        
    

省略若干行代码~ , 轻松通过VO第二轮

final round:月度最受欢迎地点

Given a log file of timestamp, customerId, locationId where

timestamp: yyyy-MM-ddTHH:mm:ss.zzz
customerId: GUID
locationId: GUID

  1. Identify which location is the most visited by customers in a given month.

Given:

String[] File.getLogEntries() -> this returns an array of Strings containing each row in the file as a string.
int Datetime.getMonth(datetime) -> this will return the Month as an integer from 01 to 12.

Row Example:

2025-05-29T10:31:00.000,abcde-fghi-jklmno,12345-6789-0123456

给定格式 "YYYY-MM-ddTHH:mm:ss.SSS,customerId,locationId" 的日志数组,统计指定月份访问量最高的地点 ID。

解题思路

  • 日志解析split(',') 拆分,调用 Datetime.getMonth() 筛选目标月
  • 整体思路:一次遍历完成统计,选出最大值
  • 模块化:再扩展成 “客户最爱地点”“高频访客列表”
        
""" 
Logic Thoughts
For each log entry:
Parse the string into timestamp, customerId, locationId
Extract the month from timestamp
If the month matches the target month:

Count visits to each locationId
Return the locationId with the highest count

"""

        
    

省略若干行代码~ , 轻松通过final round

        
### Example
logEntries = [
    "2025-05-29T10:31:00.000,cust123,locA",
    "2025-05-01T08:00:00.000,cust456,locB",
    "2025-05-02T12:00:00.000,cust123,locA",
    "2025-04-10T09:00:00.000,cust111,locA"
]

print(getMostVisitedLocationInMonth(logEntries, 5))  # Output: locA

        
    

如果你也在准备Amazon、Meta、TikTok等大厂的算法与系统设计面试,却不清楚如何拆题和应对各种边界,欢迎添加微信 csvohelp,即可领取北美面试求职通关秘诀。我们也有代面试,面试辅助,OA代写等服务助您早日上岸~

Leave a Reply

Your email address will not be published. Required fields are marked *