Here are 10 top Amazon interview questions frequently asked for DSA (Data Structures and Algorithms) roles:
Arrays & Hashing:
- Two Sum: Given an array of integers and a target sum, find two numbers in the array that add up to the target. (Easy)
- Maximum Subarray: Find the contiguous subarray within an array that has the largest sum. (Easy/Medium)
Linked Lists:
- Reverse a Linked List: Reverse a singly linked list in place. (Easy)
- Merge Two Sorted Linked Lists: Merge two sorted linked lists into a single sorted linked list. (Easy/Medium)
Stacks & Queues:
- Implement a Stack with min() in O(1) time: Create a stack data structure with push(), pop(), and min() operations, all taking constant time. (Medium)
Trees:
- Lowest Common Ancestor (LCA) in a Binary Search Tree (BST): Find the lowest common ancestor of two given nodes in a BST. (Medium)
- Level Order Traversal of a Binary Tree: Traverse a binary tree level by level, visiting all nodes at each level from left to right. (Easy/Medium)
Searching & Sorting:
- Search in a Rotated Sorted Array: Search for a given element in a sorted array that has been rotated an unknown number of times. (Medium)
- Kth Largest Element: Find the kth largest element in an unsorted array. (Medium)
Others:
- Trapping Rain Water: Given a collection of buildings represented by heights, calculate how much rainwater could be trapped between them. (Medium)