Code Question 1
Amazon operates a network of n
distribution centers, each located in a different city. The cities are numbered from 1 to n. Given a list of orders, where each order is destined for a city specified in orderCityList[i]
:
- Delivery from the distribution center in the same city takes 1 day.
- Delivery from a distribution center in another city takes 2 days due to the longer distance.
Each distribution center can handle one order at a time, and orders from the same center are processed sequentially — only one order is delivered at a time, and the next order will be processed once the previous one has been delivered. Multiple centers can process orders simultaneously.
Task: Determine the minimum number of days to fulfill all orders by optimally assigning them to the distribution centers.
Example:
Given n = 3 and orderCityList = [1, 1, 3, 1, 1, 1]
- Center 1: orders 1, 2, 4 → all same city, each takes 1 day → total 3 days.
- Center 2: order 5 → to city 3 (different city) → takes 2 days.
- Center 3: order 3 → same city → 1 day.
All orders delivered in 3 days.
Constraints:
1 ≤ n ≤ 2×10^5
1 ≤ orderCityList[i]
≤ n

Code Question 2
Amazon’s database stores numbers as strings of binary characters '0' and '1'. Accidentally, a '!' appears in some positions, representing an unknown character that can be replaced with either '0' or '1'.
Due to internal faults:
- Every subsequence
"01"
generates x errors. - Every subsequence
"10"
generates y errors.
A subsequence of a string is obtained by deleting zero or more characters without changing the order of the remaining characters.
Task: Determine the minimum total errors possible after optimally replacing each '!'. Return the result modulo 10^9+7.
Example:errorString = "0!111"
, x = 2, y = 3
If '!' → '0':
- String: "00111"
- "01" subsequences = 9 → errors = 9×x = 18
- "10" subsequences = 0 → errors = 0×y = 0
- Total = 18
If '!' → '1':
- String: "01111"
- "01" subsequences = 3 → errors = 3×x = 6
- "10" subsequences = 0 → errors = 0×y = 0
- Total = 6
Minimum errors = 6 (modulo 10^9+7).
Constraints:
1 ≤ length(errorString) ≤ 10^5
1 ≤ x, y ≤ 10^5

我们长期稳定承接各大科技公司如Adyen、TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.
