🔥 Amazon SDE Interview Questions (Real Experiences + LeetCode Links)
Summary
I've compiled a comprehensive list of Amazon SDE interview questions gathered from various real candidate experiences on platforms like Reddit and LeetCode Discuss. This provides a clear overview of the types of coding, design, and behavioral problems typically encountered.
Full Experience
After meticulously reviewing numerous Amazon Software Development Engineer interview experiences, I've identified recurring patterns and specific problems that candidates face. These insights span from new-grad loops to SDE1 roles across different global locations like the US and India. The coding rounds consistently feature problems similar to those found on LeetCode, covering various data structures and algorithms.
I've noted instances of problems requiring dynamic programming with bitmasking, graph traversal, tree manipulations, and string processing. Behavioral questions, often framed around Amazon's Leadership Principles, are also a standard part of the process, sometimes integrated with technical discussions. Some rounds specifically test system design and low-level design capabilities. Overall, the process appears to be rigorous, demanding a solid foundation in core computer science concepts and problem-solving.
Interview Questions (49)
Find the majority element in an array. The majority element is the element that appears more than ⌊n / 2⌋ times.
Find the lowest common ancestor of two nodes in an N-ary tree.
Compress a string such that consecutive repeating characters are replaced with the character and count, e.g., 'aaabbbccc' -> 'a3b3c3'.
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.
Given a string s, return the longest palindromic substring in s.
Implement the atoi function, which converts a string to an integer, handling various edge cases like whitespace, sign, and overflow.
Convert an integer to its Roman numeral representation.
Convert a Roman numeral string to its integer representation.
Given a string s containing just the characters '(', ')', '{', '}', '[', ']', determine if the input string is valid.
Merge k sorted linked lists into one sorted linked list.
Determine if a 9x9 Sudoku board is valid according to Sudoku rules (each row, column, and 3x3 sub-grid must contain digits 1-9 without repetition).
Given a set of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sum to target. The same repeated number may be chosen from candidates an unlimited number of times.
Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.
Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.
Given the head of a linked list, rotate the list to the right by k places.
Given an m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path.
Given an m x n grid of characters and a string word, return true if word exists in the grid (formed by adjacent cells horizontally or vertically).
Given the root of a binary tree, determine if it is a valid binary search tree (BST).
Given the roots of two binary trees p and q, return true if they are the same tree, or false otherwise.
Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center).
Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level).
Given the head of a singly linked list where elements are sorted in ascending order, convert it to a height-balanced binary search tree.
Populate each next pointer to point to its next right node in a perfect binary tree. If there is no next right node, the next pointer should be set to NULL.
You are given an array prices where prices[i] is the price of a given stock on the i-th day. Find the maximum profit you can achieve by buying on one day and selling on a different day.
Given two words, beginWord and endWord, and a dictionary wordList, return the number of words in the shortest transformation sequence from beginWord to endWord.
Given two words, beginWord and endWord, and a dictionary wordList, return all shortest transformation sequences from beginWord to endWord.
Design and implement a Least Recently Used (LRU) cache with get and put operations, both running in O(1) average time complexity.
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.
Given an m x n 2D binary grid which represents a map of '1's (land) and '0's (water), return the number of islands.
Given the total number of courses and a list of prerequisite pairs, return true if you can finish all courses.
Given the total number of courses and a list of prerequisite pairs, return the ordering of courses you should take to finish all courses.
Design a data structure that supports adding new words and finding if a string matches any previously added word. The search function can use '.' for any single character.
Given an m x n board of characters and a list of strings words, return all words on the board that can be found by following sequences of letters.
Convert a non-negative integer to its English words representation.
Implement Conway's Game of Life. Given a 2D board representing the current state of a grid with cells that are either live (1) or dead (0), update the board to the next state.
The median is the middle value in an ordered integer list. Design a data structure that supports adding integers and finding the median of the current numbers.
Given an integer array nums, return the length of the longest strictly increasing subsequence.
Design a Tic-Tac-Toe game that can be played on an n x n grid. Implement functions to make a move and check for a winner.
Given an m x n matrix of integers representing the height of each unit cell in a continent, find a list of grid coordinates where water can flow to both the Pacific and Atlantic oceans.
Given a 2D board representing a Minesweeper game, update it to its next state given the click coordinates.
Given the root of a binary tree, return the length of the diameter of the tree. The diameter is the length of the longest path between any two nodes in a tree.
Given a string s, rearrange the characters of s such that any two adjacent characters are not the same. If it is not possible, return an empty string.
Given the root of a complete binary tree, return the number of nodes in the tree.
Given a string s, sort it in decreasing order based on the frequency of the characters.
Given an array representing n stalls and k aggressive cows, assign k cows to k stalls such that the minimum distance between any two of them is maximized.
Given a directed graph, find the node that has the highest edge score. The edge score of a node is the sum of the values of all nodes that point to it.
Given two strings s1 and s2, count the total number of substrings in s2 that are anagrams of s1.
You have an undirected, connected graph of n nodes labeled from 0 to n - 1. You are given an array graph where graph[i] is a list of all the nodes connected with node i by an edge. Return the length of the shortest path that visits every node in the graph. You may start and stop at any node, and you may revisit nodes multiple times. The problem is a variant of TSP solvable with DP + bitmasking.
Preparation Tips
Based on these collective experiences, my preparation would involve a strong focus on LeetCode problems, particularly those frequently reported by Amazon candidates. I would categorize and practice problems across common themes like arrays, strings, trees, graphs, dynamic programming, and data structure design. Additionally, I would dedicate time to understanding and articulating solutions to system design questions and meticulously prepare examples for behavioral questions aligned with Amazon's Leadership Principles. Reviewing specific LeetCode problem patterns, especially those involving optimized approaches like DP with bitmasking, would be crucial.