๐ฅ 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)
Majority Element
Find the majority element in an array. The majority element is the element that appears more than โn / 2โ times.
Lowest Common Ancestor of N-ary Tree
Find the lowest common ancestor of two nodes in an N-ary tree.
String Compression
Compress a string such that consecutive repeating characters are replaced with the character and count, e.g., 'aaabbbccc' -> 'a3b3c3'.
Two Sum
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
Median of Two Sorted Arrays
Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.
Longest Palindromic Substring
Given a string s, return the longest palindromic substring in s.
String to Integer (atoi)
Implement the atoi function, which converts a string to an integer, handling various edge cases like whitespace, sign, and overflow.
Integer to Roman
Convert an integer to its Roman numeral representation.
Roman to Integer
Convert a Roman numeral string to its integer representation.
Valid Parentheses
Given a string s containing just the characters '(', ')', '{', '}', '[', ']', determine if the input string is valid.
Merge K Sorted Lists
Merge k sorted linked lists into one sorted linked list.
Valid Sudoku
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).
Combination Sum
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.
Permutations
Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.
Merge Intervals
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.
Rotate List
Given the head of a linked list, rotate the list to the right by k places.
Minimum Path Sum
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.
Word Search
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).
Validate Binary Search Tree
Given the root of a binary tree, determine if it is a valid binary search tree (BST).
Same Tree
Given the roots of two binary trees p and q, return true if they are the same tree, or false otherwise.
Symmetric Tree
Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center).
Binary Tree Level Order Traversal
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).
Convert Sorted List to Binary Search Tree
Given the head of a singly linked list where elements are sorted in ascending order, convert it to a height-balanced binary search tree.
Populating Next Right Pointers in Each Node
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.
Best Time to Buy and Sell Stock
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.
Word Ladder
Given two words, beginWord and endWord, and a dictionary wordList, return the number of words in the shortest transformation sequence from beginWord to endWord.
Word Ladder II
Given two words, beginWord and endWord, and a dictionary wordList, return all shortest transformation sequences from beginWord to endWord.
LRU Cache Design
Design and implement a Least Recently Used (LRU) cache with get and put operations, both running in O(1) average time complexity.
Min Stack Design
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.
Number of Islands
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.
Course Schedule
Given the total number of courses and a list of prerequisite pairs, return true if you can finish all courses.
Course Schedule II
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 Add and Search Word Data Structure
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.
Word Search II
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.
Integer to English Words
Convert a non-negative integer to its English words representation.
Game of Life
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.
Find Median from Data Stream
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.
Longest Increasing Subsequence
Given an integer array nums, return the length of the longest strictly increasing subsequence.
Design Tic-Tac-Toe
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.
Pacific Atlantic Water Flow
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.
Minesweeper
Given a 2D board representing a Minesweeper game, update it to its next state given the click coordinates.
Diameter of Binary Tree
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.
Reorganize String
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.
Count Nodes in Complete Binary Tree
Given the root of a complete binary tree, return the number of nodes in the tree.
Sort Characters by Frequency
Given a string s, sort it in decreasing order based on the frequency of the characters.
Aggressive Cows
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.
Directed Graph Edge Score
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.
Count Anagrammatic Substrings
Given two strings s1 and s2, count the total number of substrings in s2 that are anagrams of s1.
Shortest Path Visiting All Nodes (LC 847)
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.