Amazon Fresher / SDE-1
Amazon SDE-1.NET Interview
L4 Loop for 0-2 years: 2 Coding + 1 Leadership Principle. No system design. Salary: ₹1.3Cr - ₹1.8Cr
⚠️ Amazon SDE-1 Bar: You must write compiling code + handle edge cases + explain Big-O. "Almost works" = reject. LP answers need metrics even at fresher level.
Amazon SDE-1 Loop: What to Expect
| Round | Time | What They Test | Pass Rate |
|---|---|---|---|
| Coding 1 | 45m | Leetcode Easy-Medium. String/Array/HashMap. Must run. | 60% |
| Coding 2 | 45m | OOP Design +.NET Basics. IEnumerable, async basics, LINQ | 55% |
| LP Round | 45m | 1-2 Leadership Principles. "Bias for Action", "Ownership". STAR format. | 70% |
2025-2026 Real SDE-1.NET Questions - 15 Must-Know
Question: Given
Expected Answer: HashMap for O(n). Store value→index. Check if
Amazon follow-up 2: What if duplicates? Return any pair, so this works.
Bar Raiser Trap: Nested for-loop O(n^2) = reject. Or not checking
int[] nums and target, return indices of two numbers that add up. Use C#.Expected Answer: HashMap for O(n). Store value→index. Check if
target - nums[i] exists.
Dictionary<int,int> map = new();
for(int i=0; i<nums.Length; i++) {
int need = target - nums[i];
if(map.ContainsKey(need)) return new[]{map[need], i};
map[nums[i]] = i;
}
Amazon follow-up 1: What if array is sorted? Answer: Two pointers, O(1) space.Amazon follow-up 2: What if duplicates? Return any pair, so this works.
Bar Raiser Trap: Nested for-loop O(n^2) = reject. Or not checking
ContainsKey before access = KeyNotFoundException.
Question: Check if string of
Expected Answer: Use Stack. Push opening, pop on closing and check match. O(n) time, O(n) space.
Follow-up: What if input has other chars? Ignore them or return false - clarify with interviewer first.
()[]{} is valid. "([)]" = false.Expected Answer: Use Stack. Push opening, pop on closing and check match. O(n) time, O(n) space.
bool IsValid(string s) {
var stack = new Stack<char>();
var map = new Dictionary<char,char>{{')','('},{'}','{'},{']','['};
foreach(char c in s) {
if("({[".Contains(c)) stack.Push(c);
else if(stack.Count==0 || stack.Pop()!=map[c]) return false;
}
return stack.Count==0;
}
Why they ask: Tests stack basics + edge cases. Empty string = true. One char = false.Follow-up: What if input has other chars? Ignore them or return false - clarify with interviewer first.
Question: You return 1M users from DB. Return type:
Expected Answer:
1.
2.
3.
Amazon trap: Calling
IEnumerable<User> vs List<User> vs IQueryable<User>?Expected Answer:
1.
IQueryable<User>: Best for DB. Keeps query composable. db.Users.Where() adds to SQL, not in-memory.2.
IEnumerable<User>: For in-memory or streaming. Deferred execution, but if from EF Core, each iteration hits DB.3.
List<User>: Worst. Forces .ToList(), loads 1M to RAM = OOM. Only use if you need Count or multiple iterations.Amazon trap: Calling
.Count() on IQueryable runs SELECT COUNT(*). Calling it on IEnumerable loads all then counts = slow.
Question: Design LRU Cache with
SDE-1 Answer: Dictionary + Doubly Linked List. Dictionary for O(1) lookup, DLL for O(1) remove/add to head.
Follow-up: Thread-safe? Answer: Wrap with
Get(key) and Put(key,val) in O(1).SDE-1 Answer: Dictionary + Doubly Linked List. Dictionary for O(1) lookup, DLL for O(1) remove/add to head.
public class LRUCache {
class Node { public int key,val; public Node prev,next; }
Dictionary<int,Node> map = new(); int cap; Node head,tail;
public int Get(int key) {
if(!map.ContainsKey(key)) return -1;
var node = map[key]; Remove(node); AddToHead(node); return node.val;
}
}
Why SDE-1 gets this: Tests hash map + linked list combo. Amazon loves cache questions.Follow-up: Thread-safe? Answer: Wrap with
lock or use ConcurrentDictionary + careful ordering.
Question: Why does this deadlock in ASP.NET?
Expected Answer: ASP.NET has SynchronizationContext.
Fix 1:
Fix 2:
Why they ask: #1 production bug for junior devs. Shows you understand threading model.
var result = GetDataAsync().Result;Expected Answer: ASP.NET has SynchronizationContext.
.Result blocks thread waiting for task. Task wants to resume on same context when await completes. But context thread is blocked = deadlock. Console apps don't have SyncContext, so no deadlock.Fix 1:
await GetDataAsync(); all the way up.Fix 2:
.ConfigureAwait(false) in library code to not capture context.Why they ask: #1 production bug for junior devs. Shows you understand threading model.
Question: Reverse a singly linked list. Iterative + recursive.
Iterative O(n) time O(1) space:
Trap: Losing
Iterative O(n) time O(1) space:
ListNode prev = null, curr = head;
while(curr!= null) {
var next = curr.next; curr.next = prev;
prev = curr; curr = next;
}
return prev;
Follow-up: Reverse in groups of K. Amazon L4 asked this in 2026. Need dummy node + careful pointer juggling.Trap: Losing
next pointer before reassigning. Draw boxes.
Question: Concatenate 10k strings. Use
Answer:
Numbers: 10k concats: string = 200ms+, StringBuilder = 1ms.
Amazon follow-up: When is
string + or StringBuilder? Why?Answer:
StringBuilder. string is immutable. s += "x" creates new string each time = O(n^2) total, lots of GC. StringBuilder.Append uses mutable buffer = O(n).Numbers: 10k concats: string = 200ms+, StringBuilder = 1ms.
Amazon follow-up: When is
string + OK? Answer: Compiler optimizes "a"+"b"+"c" to one concat. But in loops, always StringBuilder.
Question: Implement binary search. Return index or -1.
Key points SDE-1 misses:
Key points SDE-1 misses:
int l=0, r=nums.Length-1;
while(l <= r) { // <= not <
int mid = l + (r-l)/2; // Prevent overflow, not (l+r)/2
if(nums[mid]==target) return mid;
else if(nums[mid] < target) l = mid+1;
else r = mid-1;
}
Traps: 1. mid = (l+r)/2 overflows for large arrays. 2. while(l<r) misses last element. 3. Not handling duplicates - return any index is fine unless asked for first/last.
Question: When to use interface vs abstract class in C#?
Answer:
Interface: Contract only. Multiple inheritance. No state. Use for "can-do" capability:
Abstract class: Can have state, constructors, partial implementation. Single inheritance. Use for "is-a" with shared code:
Amazon example:
Answer:
Interface: Contract only. Multiple inheritance. No state. Use for "can-do" capability:
IEnumerable, IDisposable. Since C#8 can have default methods, but still no fields.Abstract class: Can have state, constructors, partial implementation. Single inheritance. Use for "is-a" with shared code:
Stream base class.Amazon example:
ILogger = interface, because Serilog/NLog/Log4Net all implement. DbContext = abstract class, because EF gives you base behavior.
Question: "Tell me time you used data to make a decision"
SDE-1 STAR with metrics:
S: Our college hackathon API for food delivery was timing out at 50 users.
T: I needed to find root cause before 200-user demo.
A: Added Application Insights. Saw 90% time in
R: p95 latency 2.1s → 95ms. Handled 300 concurrent users in demo. Won 1st place.
Key: Metrics, tool names, specific code change. "We optimized" = reject.
SDE-1 STAR with metrics:
S: Our college hackathon API for food delivery was timing out at 50 users.
T: I needed to find root cause before 200-user demo.
A: Added Application Insights. Saw 90% time in
SELECT * FROM Orders WHERE UserId = @id with no index. Created index: CREATE INDEX IX_Orders_UserId. Also saw EF N+1: fixed with .Include(o => o.Items).R: p95 latency 2.1s → 95ms. Handled 300 concurrent users in demo. Won 1st place.
Key: Metrics, tool names, specific code change. "We optimized" = reject.
Question: What happens:
Answer: Boxing: Value type
Where it hurts:
Amazon follow-up: How to avoid? Answer: Generics,
int i = 5; object o = i; int j = (int)o;Answer: Boxing: Value type
int copied to heap, object reference created. Unboxing: Cast back, copies heap value to stack. Perf cost + GC pressure.Where it hurts:
ArrayList boxes everything. Use List<int> generic to avoid.Amazon follow-up: How to avoid? Answer: Generics,
Span<T>, struct with no boxing.
Question: Given string, find index of first non-repeating char. "leetcode" → 0 for 'l'.
Answer: Two pass with dictionary. Or int[26] for lowercase only.
Answer: Two pass with dictionary. Or int[26] for lowercase only.
int[] count = new int[26];
foreach(char c in s) count[c-'a']++;
for(int i=0; i<s.Length; i++)
if(count[s[i]-'a']==1) return i;
return -1;
Follow-up: Stream of chars? Use Queue + HashMap to track. Amazon asked this 2026.
Question: Difference: AddTransient vs AddScoped vs AddSingleton?
Answer:
1. Transient: New instance every time. Use for lightweight stateless:
2. Scoped: One per HTTP request. Use for
3. Singleton: One for app lifetime. Use for
Amazon trap: Injecting Scoped DbContext into Singleton service = captive dependency, crashes. Interviewer tests this.
Answer:
1. Transient: New instance every time. Use for lightweight stateless:
IEmailService.2. Scoped: One per HTTP request. Use for
DbContext. New request = new DbContext.3. Singleton: One for app lifetime. Use for
IConfig, caches. Careful: can cause memory leaks.Amazon trap: Injecting Scoped DbContext into Singleton service = captive dependency, crashes. Interviewer tests this.
Question: "Time you took calculated risk"
Answer framework: Amazon loves "I shipped in 2 days vs 2 weeks" stories.
S: Payment service was down, losing $10k/hour. Team wanted 1 week to rewrite.
T: I proposed 4-hour hotfix to unblock, then proper fix later.
A: Added circuit breaker + fallback to cached rates. Deployed behind feature flag. Monitored.
R: Revenue restored in 3 hours. Zero customer impact. Later did full rewrite. Learned: bias for action > perfect code when $ burning.
Don't say: "I waited for manager approval" - Amazon wants ownership.
Answer framework: Amazon loves "I shipped in 2 days vs 2 weeks" stories.
S: Payment service was down, losing $10k/hour. Team wanted 1 week to rewrite.
T: I proposed 4-hour hotfix to unblock, then proper fix later.
A: Added circuit breaker + fallback to cached rates. Deployed behind feature flag. Monitored.
R: Revenue restored in 3 hours. Zero customer impact. Later did full rewrite. Learned: bias for action > perfect code when $ burning.
Don't say: "I waited for manager approval" - Amazon wants ownership.
Question: Your API memory grows 100MB/hour. How to debug?
SDE-1 Answer:
1. dotnet-counters: Check Gen2 heap size, GC count. If Gen2 growing = leak.
2. dotnet-dump: Take heap dump, open in Visual Studio or dotnet-gcdump.
3. Common leaks: Static events not unsubscribed,
4. Fix: Use
Why they ask: Even L4 should know basic prod debugging. Amazon fires you if you OOM prod.
SDE-1 Answer:
1. dotnet-counters: Check Gen2 heap size, GC count. If Gen2 growing = leak.
2. dotnet-dump: Take heap dump, open in Visual Studio or dotnet-gcdump.
3. Common leaks: Static events not unsubscribed,
HttpClient not disposed, CancellationTokenSource not canceled, EF DbContext not disposed.4. Fix: Use
using or IAsyncDisposable. For events: -= in Dispose.Why they ask: Even L4 should know basic prod debugging. Amazon fires you if you OOM prod.
📚 SDE-1.NET Core Must-Know Topics
- LINQ: Where, Select, GroupBy, ToList vs ToArray. Deferred execution.
- OOP: Interface vs Abstract, SOLID basics, Dependency Injection
- Collections: List<T> O(1) add, Dictionary<K,V> O(1) lookup, HashSet<T> O(1) contains
- Exception: try-catch-finally, custom exceptions, using statement
- async/await: Task vs Task<T>, ConfigureAwait(false), when not to use async
- EF Core: DbContext lifecycle, DbSet, migrations, N+1 problem
- DI: AddTransient vs AddScoped vs AddSingleton. Captive dependencies
- Git: merge vs rebase, cherry-pick, resolve conflicts
🔥 Top 5 SDE-1 Reject Reasons from 2025
- Code doesn't compile or throws NullReferenceException on happy path
- Can't explain time complexity: Says "O(n^2) is fine for 1M items" = reject
- LP story has no data: "I improved it" vs "Improved p99 from 800ms to 120ms"
.ToList()on IQueryable from DB - loads entire table to memory- Don't know basic.NET: "What is GC?" = blank stare. Or "string is value type"
Cracked SDE-1? Level Up to SDE-2
SDE-2 adds System Design + Bar Raiser. Salary jumps to ₹2.1Cr+. Same.NET, harder problems.
Master rate limiters, SQS design, and "Why.NET not Java?" defense.
Start SDE-2 Prep →100% free. Real 2025-2026 questions. No login.
No comments yet. Be the first to share your thoughts!