I mostly make my own resources based on previous data.
These are set of question being asked in Amazon SDE2 role since June 2025
to September 2025
DirectLeetcode Questions :
https://leetcode.com/problems/max-consecutive-ones-iii/ ** ✅
https://leetcode.com/problems/maximum-profit-in-job-scheduling/ ** ✅✅
https://leetcode.com/problems/task-scheduler/description/ ✅
https://leetcode.com/problems/basic-calculator/description/ ✅
https://leetcode.com/problems/reconstruct-itinerary/description/ ** ✅
https://leetcode.com/problems/remove-k-digits/description/ ✅
https://leetcode.com/problems/all-oone-data-structure/description/ ✅
https://leetcode.com/problems/maximum-subarray-sum-with-one-deletion/description/ ** ✅
https://leetcode.com/problems/remove-duplicate-letters/description/ ✅
https://leetcode.com/problems/row-with-maximum-ones/description/ ✅
https://leetcode.com/problems/group-anagrams ✅
https://leetcode.com/problems/find-median-from-data-stream/description/ ** ✅
https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii/description/
https://leetcode.com/problems/making-a-large-island/description/
https://leetcode.com/problems/number-of-islands/ ✅
https://leetcode.com/problems/sliding-window-maximum/ ** ✅
https://leetcode.com/problems/rotting-oranges/description/ ✅
https://leetcode.com/problems/gas-station/description/ ✅
https://leetcode.com/problems/lfu-cache/description/
https://leetcode.com/problems/bus-routes/description/
https://leetcode.com/problems/evaluate-division/description/ ** ✅
https://leetcode.com/problems/longest-happy-prefix/description/
https://leetcode.com/problems/first-missing-positive/description/ ✅
https://leetcode.com/problems/trapping-rain-water/description/ ✅
https://leetcode.com/problems/course-schedule-ii/ ✅
https://leetcode.com/problems/koko-eating-bananas/** ✅
https://leetcode.com/problems/next-permutation/description/ ✅
https://leetcode.com/problems/pacific-atlantic-water-flow/description/ ***✅
https://leetcode.com/problems/find-all-possible-recipes-from-given-supplies/description/
https://leetcode.com/problems/group-anagrams/description/ ✅
https://leetcode.com/problems/maximum-tastiness-of-candy-basket/description/
https://leetcode.com/problems/concatenated-words ✅
https://leetcode.com/problems/insert-delete-getrandom-o1/description/ ✅
https://leetcode.com/problems/design-twitter/description/ ✅
https://leetcode.com/problems/insert-delete-getrandom-o1-duplicates-allowed/description/ ✅
https://leetcode.com/problems/word-ladder/description/
https://leetcode.com/problems/amount-of-time-for-binary-tree-to-be-infected/description/ ✅
https://leetcode.com/problems/remove-k-digits/description/ ✅
https://leetcode.com/problems/magnetic-force-between-two-balls/description/ ✅
https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree/description/ ✅
https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards/description/
https://leetcode.com/problems/asteroid-collision/description/ ✅
https://leetcode.com/problems/boats-to-save-people/ ✅
https://leetcode.com/problems/number-of-pairs-of-interchangeable-rectangles/description/
https://leetcode.com/problems/minimize-max-distance-to-gas-station/description/
Non Leetcode Questions:
Calculate the sum of each subarray of size K for an array. ** ✅
arr = [1,3,-1,-3,5,3,6,7]
k = 3
n = len(arr)
res = []
left,right = 0,0
cur = 0
while right < n :
cur += arr[right]
if right - left + 1 > k :
cur -= arr[left]
left += 1
if right - left + 1 == k :
res.append(cur)
right += 1
print(res)Follow Up: **Return the max of each window instead of the sum. https://leetcode.com/problems/sliding-window-maximum/ ✅
Crypto Numbers
3. Given two integers n and m, find all the crypto numbers in the range [n, m]. A number is called a crypto number if all adjacent digits have an absolute difference of 1.
Example:
Input: n = 0, m = 15
Output: 0 1 2 3 4 5 6 7 8 9 10 12
Input: n = 20, m = 25
Output: 21 23
-----------------
def find_tree_height(parent):
n = len(parent)
depth = [-1] * n # To store depth of each node
def get_depth(i):
if depth[i] != -1:
return depth[i]
if parent[i] == -1:
depth[i] = 0 # Root node
else:
depth[i] = get_depth(parent[i]) + 1
return depth[i]
max_depth = 0
for i in range(n):
max_depth = max(max_depth, get_depth(i))
return max_depth
parent = [4, 3, 0, 6, 6, 3, -1, 0]
print(find_tree_height(parent))Pattern Anagram ✅
Q1: Given two strings str and pattern, return an array of all the start indices of pattern's anagrams in str.
Input: str = "acbadabcaa", pattern = "aabc" Output: [0,5,6] Explanation:
The substring with start index = 0 is "acba", which is an anagram of "aabc".
The substring with start index = 5 is "abca", which is an anagram of "aabc".
The substring with start index = 6 is "bcaa", which is an anagram of "aabc".
--------------------------------------------------------------------------
str = "acbadabcaa"
pattern = "aabc"
#Output: [0,5,6] Explanation:
def solution(s, pat):
res = []
pat_occurence = {}
for ele in pat:
pat_occurence[ele] = pat_occurence.get(ele,0) + 1
len_pat = len(pattern)
s_occurence = {}
needed = len(pat_occurence)
have = 0
left = 0
for right, ele in enumerate(s):
if pat_occurence.get(ele):
s_occurence[ele] = s_occurence.get(ele,0) + 1
if s_occurence[ele] == pat_occurence[ele]:
have += 1
if have == needed :
res.append(right + 1 - len_pat)
s_occurence[s[left]] -= 1
if pat_occurence.get(s[left]) and s_occurence[ele] < pat_occurence[ele]:
have -= 1
left += 1
else:
s_occurence = {}
have = 0
left = right + 1
return res
print(solution(str, pattern))
Poll Cutting ✅
Q1. There are N poles of various heights, and you have a machine whose saw blade can be set at a specific height "h"
and it cuts all poles till that height, such that all of them have height "h" after the cut.
(Poles with height less than "h" remain uncut). You take away the cut portions of all poles with you.
Your task is to take at least M length of poles with you in total after the cut.
What is the maximum height 'h' where you can set your blade to achieve this.
N = 4
M = 7
arr = [20, 15, 10, 17]Maximum Height of the tree ✅
You need to find the height of a tree given its parent-child relationship in an array where each index represents a node, and the value at that index represents its parent. The root node has a value of -1.
Input: [4, 3, 0, 6, 6, 3, -1, 0]
Output: 4
def find_tree_height(parent):
n = len(parent)
depth = [-1] * n # To store depth of each node
def get_depth(i):
if depth[i] != -1:
return depth[i]
if parent[i] == -1:
depth[i] = 0 # Root node
else:
depth[i] = get_depth(parent[i]) + 1
return depth[i]
max_depth = 0
for i in range(n):
max_depth = max(max_depth, get_depth(i))
return max_depthCustomer Serve
Customers arrive at different times, and each customer has a different number of items to scan, which determines how long they take at the checkout counter.
The store has only one checkout counter, meaning it can serve only one customer at a time.
The checkout system follows these rules:
If no customers are waiting, the counter remains idle.
When the counter is free and multiple customers are waiting, it serves the customer with the fewest items first (shortest checkout time).
If two customers have the same number of items, the one who arrived first is served first.
Once a checkout begins, it must be fully completed before moving to the next customer.
The counter instantly moves to the next available customer once the current checkout finishes.
Input :
You are given an integer n representing the number of customers and a 2D integer array customers, where:
customers[i] = [arrivalTimeᵢ, checkoutDurationᵢ]
Output :
Return an integer array of size n, representing the order in which customers will be served.Social Group
In a social group of n people labeled from 0 to n - 1,friendships are being formed over time.
You are given an array logs, where each log entry logs[i] = [timestamp_i, x_i, y_i]
represents that persons x_i and y_i will become friends at time timestamp_i. Each friendship is transitive.
For millions of such datapoint, find the earliest timestamp, at which all people become friends.
I gave a LinkedList/Set with Map approach. But this question would be solved by Disjoint set, and got the rejection.No two elements are side by side
The problem given was to reorganize a string so that no two same characters are next to each other. I was able to solve it, and the feedback was again “Hire”.Data Structure boolean
Design a data structure to optimize storage for array of Booleans, I used bits of an Integer to store Booleans efficiently. Also had a couple of basic Java questions.Free Server ID in a fixed pool
Design a system to allocate and free server IDs from a fixed pool of servers with IDs from 1 to N.
allocate() → Return the smallest available ID that hasn't been allocated yet. If no ID is available, return -1.
free(id) → Mark a previously allocated ID as available again.
import heapq
class ServerIDAllocator:
def __init__(self, n):
self.n = n
self.next_id = 1
self.freed_ids = [] # min-heap of freed IDs
self.freed_set = set() # to avoid re-adding freed IDs
def allocate(self):
if self.freed_ids:
smallest = heapq.heappop(self.freed_ids)
self.freed_set.remove(smallest)
return smallest
if self.next_id <= self.n:
curr = self.next_id
self.next_id += 1
return curr
return -1
def free(self, id):
if 1 <= id < self.next_id and id not in self.freed_set:
heapq.heappush(self.freed_ids, id)
self.freed_set.add(id)
Un cate
Coding Questions:-
num1 = [1, 2, 7]
num2 = [3, 14, 26]
you have to create a new array that will contain in sorted fashion.
Talked about both scenarios if input arrays are sorted or unsorted.
2.Input: orders = [[10,5,0],[15,2,1],[25,1,1],[30,4,0]]
Output: 6
type=
0 -> buy
1 -> sell
[price, qty, type]
how many orders you will not able to process.
[[7,1000000000,1],[15,3,0],[5,999999995,0],[5,1,1]]
Even solving all the question efficently in optimised way before time got a call from recutiur saying that its NO in both rounds.Radiation [Bar raiser]
You're given a list of radiation events. Each event has a start time, end time, and a radiation value. Radiation is additive for overlapping intervals.
You’re also given a threshold. Identify all time intervals where the total radiation exceeds the threshold.[Sliding Window] – Maximum fruits in 2 baskets
Print all nodes at distance K from any leaf [DFS + Tree]