2024年4月Amazon我们已经辅助过多轮，我们一起来看看它的VO都出了一些什么题吧。大家可以看看题目的难度，提前检测自己是否能够做出出来

## coding(算法题)：

**1.question1**

Given a `file`

and assume that you can only read the file using a given method `read4`

, implement a method to read `n`

characters.

**Method read4:**

The API `read4`

reads **four consecutive characters** from `file`

, then writes those characters into the buffer array `buf4`

.

The return value is the number of actual characters read.

Note that `read4()`

has its own file pointer, much like `FILE *fp`

in C.

**Definition of read4:**

Parameter: char[] buf4 Returns: int buf4[] is a destination, not a source. The results from read4 will be copied to buf4[].2.question2Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1.3.question3Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. Implement the MinStack class: MinStack() initializes the stack object. void push(int val) pushes the element val onto the stack. void pop() removes the element on the top of the stack. int top() gets the top element of the stack. int getMin() retrieves the minimum element in the stack. You must implement a solution with O(1) time complexity for each function.4.question4Given an m x n binary grid grid where each 1 marks the home of one friend, return the minimal total travel distance. The total travel distance is the sum of the distances between the houses of the friends and the meeting point. The distance is calculated using Manhattan Distance, where distance(p1, p2) = |p2.x - p1.x| + |p2.y - p1.y|.5.question5Table: SurveyLog +-------------+------+ | Column Name | Type | +-------------+------+ | id | int | | action | ENUM | | question_id | int | | answer_id | int | | q_num | int | | timestamp | int | +-------------+------+ This table may contain duplicate rows. action is an ENUM (category) of the type: "show", "answer", or "skip". Each row of this table indicates the user with ID = id has taken an action with the question question_id at time timestamp. If the action taken by the user is "answer", answer_id will contain the id of that answer, otherwise, it will be null. q_num is the numeral order of the question in the current session. The answer rate for a question is the number of times a user answered the question by the number of times a user showed the question. Write a solution to report the question that has the highest answer rate. If multiple questions have the same maximum answer rate, report the question with the smallest question_id. The result format is in the following example.

**Q6**

ou are given an `m x n`

`grid`

where each cell can have one of three values:

`0`

representing an empty cell,`1`

representing a fresh orange, or`2`

representing a rotten orange.

Every minute, any fresh orange that is **4-directionally adjacent** to a rotten orange becomes rotten.

Return *the minimum number of minutes that must elapse until no cell has a fresh orange*. If *this is impossible, return* `-1`

.

**Q7**

Given the `root`

of a binary tree, return *the sum of every tree node's tilt.*

The **tilt** of a tree node is the **absolute difference** between the sum of all left subtree node **values** and all right subtree node **values**. If a node does not have a left child, then the sum of the left subtree node **values** is treated as `0`

. The rule is similar if the node does not have a right child.

**Q8**

There are `n`

cities connected by some number of flights. You are given an array `flights`

where `flights[i] = [from`

indicates that there is a flight from city _{i}, to_{i}, price_{i}]`from`

to city _{i}`to`

with cost _{i}`price`

._{i}

You are also given three integers `src`

, `dst`

, and `k`

, return **the cheapest price** from `src`

* to *`dst`

* with at most *`k`

* stops. *If there is no such route, return* *`-1`

.

**Q9**

Given an array of `intervals`

where `intervals[i] = [start`

, merge all overlapping intervals, and return _{i}, end_{i}]*an array of the non-overlapping intervals that cover all the intervals in the input*.

**Example 1:**

Input:intervals = [[1,3],[2,6],[8,10],[15,18]]Output:[[1,6],[8,10],[15,18]]Explanation:Since intervals [1,3] and [2,6] overlap, merge them into [1,6].

**Example 2:**

Input:intervals = [[1,4],[4,5]]Output:[[1,5]]Explanation:Intervals [1,4] and [4,5] are considered overlapping.

**Q10**

You are given an array of variable pairs `equations`

and an array of real numbers `values`

, where `equations[i] = [A`

and _{i}, B_{i}]`values[i]`

represent the equation `A`

. Each _{i} / B_{i} = values[i]`A`

or _{i}`B`

is a string that represents a single variable._{i}

You are also given some `queries`

, where `queries[j] = [C`

represents the _{j}, D_{j}]`j`

query where you must find the answer for ^{th}`C`

._{j} / D_{j} = ?

Return *the answers to all queries*. If a single answer cannot be determined, return `-1.0`

.

**Note:** The input is always valid. You may assume that evaluating the queries will not result in division by zero and that there is no contradiction.

**Note: **The variables that do not occur in the list of equations are undefined, so the answer cannot be determined for them.

**Q11**

Given a `n * n`

matrix `grid`

of `0's`

and `1's`

only. We want to represent `grid`

with a Quad-Tree.

Return *the root of the Quad-Tree representing *`grid`

.

A Quad-Tree is a tree data structure in which each internal node has exactly four children. Besides, each node has two attributes:

`val`

: True if the node represents a grid of 1's or False if the node represents a grid of 0's. Notice that you can assign the`val`

to True or False when`isLeaf`

is False, and both are accepted in the answer.`isLeaf`

: True if the node is a leaf node on the tree or False if the node has four children.

class Node { public boolean val; public boolean isLeaf; public Node topLeft; public Node topRight; public Node bottomLeft; public Node bottomRight; }

We can construct a Quad-Tree from a two-dimensional area using the following steps:

- If the current grid has the same value (i.e all
`1's`

or all`0's`

) set`isLeaf`

True and set`val`

to the value of the grid and set the four children to Null and stop. - If the current grid has different values, set
`isLeaf`

to False and set`val`

to any value and divide the current grid into four sub-grids as shown in the photo. - Recurse for each of the children with the proper sub-grid.

If you want to know more about the Quad-Tree, you can refer to the wiki.

**Quad-Tree format:**

You don't need to read this section for solving the problem. This is only if you want to understand the output format here. The output represents the serialized format of a Quad-Tree using level order traversal, where `null`

signifies a path terminator where no node exists below.

It is very similar to the serialization of the binary tree. The only difference is that the node is represented as a list `[isLeaf, val]`

.

If the value of `isLeaf`

or `val`

is True we represent it as **1** in the list `[isLeaf, val]`

and if the value of `isLeaf`

or `val`

is False we represent it as **0**.

**Example 1:**

Input:grid = [[0,1],[1,0]]Output:[[0,1],[1,0],[1,1],[1,1],[1,0]]Explanation:The explanation of this example is shown below: Notice that 0 represents False and 1 represents True in the photo representing the Quad-Tree.

**Q12**

A **transformation sequence** from word `beginWord`

to word `endWord`

using a dictionary `wordList`

is a sequence of words `beginWord -> s`

such that:_{1} -> s_{2} -> ... -> s_{k}

- Every adjacent pair of words differs by a single letter.
- Every
`s`

for_{i}`1 <= i <= k`

is in`wordList`

. Note that`beginWord`

does not need to be in`wordList`

. `s`

_{k}== endWord

Given two words, `beginWord`

and `endWord`

, and a dictionary `wordList`

, return *the number of words in the shortest transformation sequence from*

`beginWord`

*to*

`endWord`

*, or*

`0`

*if no such sequence exists.*

system design (系统设计)：

- autocomplete
- 餐馆预定系统 - Restaurant Reservation System
- 推荐系统 - Recommendation System
- 电影订票系统 - Movie Ticket Booking System
- Task Scheduler - Task Scheduler (already in English)
- 用户订阅系统 - User Subscription System

## OOD (面向对象):

- pizza prices
- Amazon Locker
- Unix File Filter

## BQ (行为问题):

Conflict,

Disagree,

Invent & Simplify

Miss DDL

如果你也对Amazon感兴趣，欢迎联系我们。查看我们的服务价格，代面试，面试辅助，简历编写和算法私教等等，应有尽有。

If you are also interested in Amazon, feel free to contact us. Check out our service rates for interview proxy, interview assistance, resume writing, private algorithm tutoring, and much more—everything you need is available.