Nest

Active problem-solving

Practice Prompts

Try it before you reveal. Each coding, algorithm, and system-design prompt unfolds in stages — approach, then solution — so you practice retrieval, not recognition. Mark what you solved; revisit the rest.

Solved 0 / 31
Level
  1. CodeMid

    Paginated REST endpoint with validation + auth

    NestJSvalidationguards

    Build GET /users?page=1&limit=20 that is JWT-protected, validates query params, and returns a paginated result. Show the controller, the query DTO, and how the guard/pipe are wired.

    next: new
  2. CodeSenior

    Custom RolesGuard with the Reflector

    NestJSauthRBAC

    Implement a @Roles('admin') decorator and a RolesGuard that reads required roles from route metadata and compares them to request.user.roles. Make method-level roles override class-level.

    next: new
  3. CodeSenior

    Retry with exponential backoff + jitter

    Noderesilience

    Write retry(fn, { retries, baseMs }) that retries a failing async function with exponential backoff and jitter, only retrying transient errors, and gives up after N attempts.

    next: new
  4. CodeMid

    In-memory LRU cache (O(1))

    Nodedata structures

    Implement an LRU cache with O(1) get and set and a max capacity that evicts the least-recently-used entry.

    next: new
  5. CodeSenior

    Async pool with a concurrency limit

    Nodeasync

    Process 10,000 items by running an async worker(item) with at most N in flight at once (a bounded Promise.all). Why not just Promise.all(items.map(worker))?

    next: new
  6. CodeMid

    Response-envelope TransformInterceptor

    NestJSinterceptorsRxJS

    Write an interceptor that wraps every successful response in { data, timestamp } without each handler knowing about it.

    next: new
  7. CodeSenior

    Stream a large file with backpressure

    Nodestreams

    Serve a multi-GB file as a gzipped download without loading it into memory, and make sure errors and resources are handled.

    next: new
  8. CodeSenior

    Redis token-bucket rate limiter

    NodeRedisrate limiting

    Implement a distributed token-bucket limiter (refill rate R, capacity C) that's correct across multiple app instances. Why must it be atomic?

    next: new
  9. CodeSenior

    Fix GraphQL N+1 with DataLoader

    NestJSGraphQLperformance

    A Post.author field resolver runs one query per post over a list of 50 posts (1+50 queries). Fix it with DataLoader and explain the two classic bugs.

    next: new
  10. CodeSenior

    Graceful shutdown for a Nest service

    NestJSops

    Implement graceful shutdown so a SIGTERM (k8s rollout) drains in-flight requests and closes resources before exit.

    next: new
  11. DesignArchitect

    Design a multi-tenant SaaS API

    architecturemulti-tenancy

    Design the backend for a B2B SaaS where each tenant's data must be isolated. Cover the isolation model, tenant resolution, and how you prevent cross-tenant leakage.

    next: new
  12. DesignArchitect

    Design an event-driven order pipeline

    architecturemicroservicesmessaging

    An order flows through payment, inventory, and shipping — separate services. Design it for reliability: no double charges, no lost orders, consistent state.

    next: new
  13. DesignArchitect

    Design auth across an API gateway + microservices

    architectureauthmicroservices

    You have a gateway and several backend services. Where do you authenticate and authorize, and how do downstream services trust the caller?

    next: new
  14. DesignSenior

    Design caching for a read-heavy endpoint

    architecturecachingperformance

    A product-detail endpoint gets 50k RPS, 99% reads, data changes a few times a day. Design the caching so it's fast, fresh enough, and survives a cache miss storm.

    next: new
  15. DesignArchitect

    Design idempotent payment processing

    architectureresilience

    Clients retry on timeout, so a “charge card” request can arrive twice. Design the API + storage so a customer is never double-charged.

    next: new
  16. DesignSenior

    Design observability for a Nest service

    architectureobservability

    You're on call for a Nest API and latency just spiked. Design the observability you'd want in place to diagnose it in minutes, not hours.

    next: new
  17. CodeMid

    Sliding window: longest substring without repeats

    DSAsliding window

    Return the length of the longest substring without repeating characters. Backend tie-in: the sliding-window pattern underlies rate limiting and log-window analytics.

    next: new
  18. CodeMid

    Top-K frequent elements

    DSAheap

    Given an array, return the K most frequent elements. Backend tie-in: leaderboards, top-N metrics, merging counts from shards.

    next: new
  19. CodeMid

    Merge overlapping intervals

    DSAintervals

    Merge all overlapping intervals. Backend tie-in: scheduling, calendar/booking conflicts, compacting time ranges.

    next: new
  20. CodeSenior

    Topological sort (Kahn's algorithm)

    DSAgraph

    Order tasks so every dependency comes first; detect cycles. Backend tie-in: build/job DAGs, module init order, dependency resolution, deadlock detection.

    next: new
  21. CodeJunior

    Two Sum (hashmap)

    DSAhashmap

    Return indices of two numbers that add to a target. Backend tie-in: the hashmap-for-O(1)-lookup instinct behind dedup, joins, and caching.

    next: new
  22. CodeMid

    BFS shortest path on a grid

    DSAgraphBFS

    Find the shortest path length from top-left to bottom-right in a 0/1 grid (0 = open). Backend tie-in: graph traversal for recommendations, routing, and reachability.

    next: new
  23. CodeMid

    Implement debounce and throttle

    DSAJSutility

    Implement debounce(fn, ms) (fire after quiet period) and throttle(fn, ms) (at most once per interval). Backend tie-in: rate-limiting calls, coalescing bursts, batching writes.

    next: new
  24. CodeJunior

    Valid parentheses (stack)

    DSAstack

    Validate that brackets ()[]{} are balanced and correctly nested. Backend tie-in: parsing, tokenizing, expression evaluation.

    next: new
  25. CodeSenior

    Merge K sorted lists/streams

    DSAheap

    Merge K sorted sequences into one sorted output. Backend tie-in: merging sorted results from K database shards or K ordered partitions.

    next: new
  26. CodeSenior

    Sliding-window request counter

    DSAqueuerate limiting

    Implement a counter that reports how many requests happened in the last W ms. Backend tie-in: the data structure inside a sliding-window rate limiter.

    next: new
  27. DesignSenior

    Debug: an endpoint's latency just spiked

    performancedebugging

    p99 latency on one endpoint jumped from 80ms to 2s. You have logs, metrics, and traces. Walk through how you find and fix the cause.

    next: new
  28. CodeSenior

    Debug: memory grows until the pod is OOM-killed

    performancememory

    RSS climbs steadily over hours until k8s OOM-kills the pod. How do you find the leak?

    next: new
  29. CodeSenior

    Optimize: an endpoint runs hundreds of queries

    performancedatabase

    A list endpoint that returns 100 orders fires ~400 queries. Diagnose and fix it.

    next: new
  30. CodeSenior

    Make a CPU-bound endpoint non-blocking

    performanceworker_threads

    An endpoint generates a PDF / resizes an image synchronously and tanks throughput under load. Make it non-blocking.

    next: new
  31. DesignSenior

    Profile and fix slow startup / cold start

    performancestartup

    The service takes 8s to become ready, hurting deploys and serverless cold starts. How do you cut it?

    next: new