# Amazon OA | Amazon’s Online Assessment | 亚麻OA | 一亩三分地

Amazon’s OA are known for their rigorous and engaging questions that test a candidate’s ability to think critically and solve problems. In this blog post, we’ll coding questions that often appear: Machine Learning Data Training and Profit & Loss Analysis. These questions are designed to assess a candidate’s technical expertise and problem-solving skills, and are commonly used by Amazon to evaluate potential hires.

## INTRODUCTION

Amazon’s hiring process for technical roles relies heavily on online assessments, which evaluate a broad range of skills, from fundamental programming knowledge to advanced problem-solving abilities. In this blog, we’ll delve into two representative questions from these assessments, explore the underlying concepts, and offer strategies for tackling them.

### Amazon OA Question 1

A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).

The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked ‘Finish’ in the diagram below).

How many possible unique paths are there?

#### Example 1:

**Input:** m = 3, n = 2

**Output:** 3

**Explanation:** From the top-left corner, there are a total of 3 ways to reach the bottom-right corner:

- Right -> Right -> Down
- Right -> Down -> Right
- Down -> Right -> Right

#### Answer

## Java Code Answer

```
class Solution {
public int uniquePaths(int m, int n) {
if(m+n == 0) return 0;
int[][] mat = new int[m][n];
for(int i = 0; i < mat.length; i++)
for(int j = 0; j < mat[0].length; j++)
{
if(i == 0 || j == 0)
mat[i][j] = 1;
else
mat[i][j] = mat[i - 1][j] + mat[i][j - 1];
}
return mat[m-1][n-1];
}
}
```

### Amazon OA Question 2

You have a map that marks the location of a treasure island. Some of the map area has jagged rocks and dangerous reefs. Other areas are safe to sail in. There are other explorers trying to find the treasure. So you must figure out a shortest route to the treasure island.

Assume the map area is a two dimensional grid, represented by a matrix of characters. You must start from the top-left corner of the map and can move one block up, down, left or right at a time. The treasure island is marked as X in a block of the matrix. X will not be at the top-left corner. Any block with dangerous rocks or reefs will be marked as D. You must not enter dangerous blocks. You cannot leave the map area. Other areas O are safe to sail in. The top-left corner is always safe. Output the minimum number of steps to get to the treasure.

#### Answer

## Java Code Answer

```
import java.util.*;
class Code {
public static void main (String[] args) {
Character[][] map = {
{'O', 'O', 'O', 'O'},
{'D', 'O', 'D', 'O'},
{'O', 'O', 'O', 'O'},
{'X', 'D', 'D', 'O'}
};
int steps = 0, rows = map.length, col = map[0].length;
Queue<pos> que = new ArrayDeque<>();
que.add(new pos(0, 0));
while(!que.isEmpty()) {
int i = que.size();
steps++;
for(;i > 0; i-- ) {
pos elem = que.poll();
if (map[elem.x][elem.y] == 'X') {
System.out.println("Found the treasure in steps: " + (steps-1));
steps = -1;
que.clear();
break;
}
map[elem.x][elem.y] = 'D';
if(elem.x+1 < rows && map[elem.x+1][elem.y]!='D'){que.add(new pos(elem.x+1, elem.y));}
if(elem.x-1 >= 0 && map[elem.x-1][elem.y]!='D'){que.add(new pos(elem.x-1, elem.y));}
if(elem.y+1 < col && map[elem.x][elem.y+1]!='D'){que.add(new pos(elem.x, elem.y+1));}
if(elem.y-1 >= 0 && map[elem.x][elem.y-1]!='D'){que.add(new pos(elem.x, elem.y-1));}
}
}
if(steps!=-1) System.out.println("Treasure is not present on this map");
}
public static class pos {
int x;
int y;
pos(int i, int j) {
x = i;
y = j;
}
}
}
```

## CONCLUSION

Amazon’s online tests are designed to test and assess candidates’ technical skills. By understanding and practicing key principles regularly, your odds of succeeding on these assessments increase greatly.

Common topics for examination include Machine Learning Data Training and Profit & Loss Analysis questions – So prepare thoroughly if this test comes knocking! With confidence!

Wishing your plans of joining an elite tech firm a success!

Effective data manipulation and optimization are vital in real-world applications like server scaling and cart management. With the appropriate algorithms in place, we can achieve optimal performance while providing seamless user experiences.

If you have any questions or would like to discuss these problems further, contact us!

经过我们的强力面试辅助，OA代写，候选人通过这些面试题的解析和沟通，面试官不仅了解了**候选人**的编程能力，也看到了我在解决问题过程中清晰的思路和有效的沟通技巧。这些不仅有助于应对Amazon的面试，同时也能提升我们解决实际编程问题的能力。祝大家面试顺利！

如果你也需要我们的面试辅助服务，请立即联系我们。