Position: SDE3 AWS Group
I will post here as it is still fresh. I finished the interview last week.
DISCLAIMER: I know this post will be "controversial", as I will expose some concerns that I had once I started this process.
Amazon takes the "Frugality" really serious:
Let me start by saying that I got the traditional Linkedin invitation, online assessment (the same questions mentioned in the other post), and eventually got called to be the on-site interview.
5 Rounds of the interview heavily focused on the 14 Leadership skills. Another half, straight out of LeetCode questions.
On the day of my interview, other 5 guys were interviewing as well, so the pile a bunch of candidates, I guess it was 5 in the morning and 5 in the afternoon for two days.
First Round (AWS Developer) :
Amazon leadership principals
https://leetcode.com/problems/first-unique-character-in-a-string/
public int firstUniqChar(String s) {
int[] map = new int[256];
for(char c: s.toCharArray())
map[c-'a']++;
int i = 0;
for(char c: s.toCharArray()){
if(map[c-'a'] == 1) return i;
i++;
}
return -1;
}Second Round (AWS Senior developer)
Amazon leadership principals
Integer array representing building heights, you start on the first position, min steps to reach the end. Each position represents how many jumps you can perform https://leetcode.com/problems/jump-game-ii/
class Solution {
int INVALID = Integer.MAX_VALUE;
Map<Integer, Integer> cache = new HashMap<>();
public int jump(int[] nums) {
return countJumps(nums, 0);
}
public int countJumps(int[] nums, int i) {
if (cache.containsKey(i))
return cache.get(i);
if (i >= nums.length - 1) {
cache.put(i, 0);
return 0;
}
if (i > 0 && nums[i] < nums[i - 1])
return (cache.containsKey(i) ? cache.get(i) : INVALID);
for (int k = 1; k <= nums[i] && i + k < nums.length; k++) {
int temp = countJumps(nums, i + k);
if (temp != INVALID && temp + 1 < (cache.containsKey(i) ? cache.get(i) : INVALID))
cache.put(i, countJumps(nums, i + k) + 1);
}
return cache.containsKey(i) ? cache.get(i) : INVALID; //needs recheck the cache.
}
}Third round (with an AWS Architect)
Fourth Round (AWS Commerce Manager)
Fifth Round (AWS Manager)
Amazon leadership principals
Given a matrix with integers, each cell represents a ground elevation, after the rain lakes are formed. Find how many lakes were formed. A lake is an elevation where the four cardinal directional cells are higher. The borders are Negative INF. Similar to https://leetcode.com/problems/number-of-islands/
public class NumberOfLakes {
int[][] coord = new int[][] {{0, 1 }, {0, -1 }, {1, 0 }, {-1, 0 } };
int countLakes(int[][] m) {
if (m == null || m.length == 0 || m[0].length == 0)
return 0;
int count = 0;
boolean[][] visited = new boolean[m.length][m[0].length];
for (int i = 1; i < m.length - 1; i++) {
for (int j = 1; j < m[0].length - 1; j++) {
if (visited[i][j]) continue;
count += isLake(m, i, j, m[i][j], visited) ? 1 : 0;
}
}
return count;
}
boolean isLake(int[][] m, int i, int j, int value, boolean visited[][]) {
if (i <= 0 || j <= 0 || i >= m.length - 1 || j >= m[0].length - 1) return false;
visited[i][j] = true;
for (int[] c : coord) {
int x = i + c[0];
int y = j + c[1];
if (x < 0 || y < 0 || x >= m.length || y >= m[0].length) continue;
int v = m[x][y];
if (v < value) return false;
else if (visited[x][y]) continue;
else if (v == value && !isLake(m, x, y, value, visited)) return false;
}
return true;
}
}