🟢 DAY 1 — Core Foundations (SDE-2 Level)
Concepts Introduced Today
You’ll practice:
No advanced patterns yet — focus is correctness + clarity.
✅ Problem 1: Rate Limiter (Sliding Window, Single Node)
🔹 New Concept (Short Explanation)
Sliding Window Rate Limiter
Instead of fixed buckets:
Track timestamps of requests Allow request if count in last windowSize ≤ limit Example:
Limit = 3 requests / 10 seconds
Requests at times:
t=1 -> allowed
t=2 -> allowed
t=3 -> allowed
t=9 -> ❌ blocked (3 already in window)
t=11 -> allowed (t=1 expired)
Key challenges:
📌 Problem Statement
Design an in-memory rate limiter.
Requirements
Example
limit = 2 requests / 5 seconds
request("user1") -> true
request("user1") -> true
request("user1") -> false
(wait 5 seconds)
request("user1") -> true
🧩 Java Interface (DO NOT MODIFY)
public interface RateLimiter {
boolean allowRequest(String userId);
}
🧪 Driver Code (Auto Tests + Edge Cases)
🎯 What Interviewer Evaluates