LLD Guide · Module 1: Foundations · Lesson 01.01
How Cruscible LLD Problems Work: Contracts, Graders and Scores
Read this first. What the grader runs, what it scores, and what it ignores.
By Cruscible Engineering · Published
Every LLD problem on Cruscible is graded by running your code, not by reading it. Knowing how that works is the fastest way to stop losing points you didn't know were on the table.
This is chapter 1 of the LLD Guide. If you have never solved an LLD problem here, read it before opening one. The next chapters cover thread-safety, Redis, Postgres, and how to design a solution before you write it.
1. The shape of every problem
A Cruscible LLD problem has three parts:
- A brief. A real system in a few paragraphs: a parking lot, a rate limiter, a deployment pipeline.
- A contract. A Java interface (or the equivalent in Python, Go or Node). It's the only thing the grader talks to.
- A grader. Hidden test scenarios that call your contract the way a real caller would: in sequence, in parallel, with bad input, and under load.
You write one class that implements the contract:
public class RetryEngineImpl implements RetryEngineContract {
// your state: fields, maps, locks
public RetryEngineImpl() {
// set up empty state
}
// implement every method of RetryEngineContract
}
There is no main, no HTTP server and no framework. The grader constructs your class and calls methods on it.
💡 Tip: Open the SDK tab before you write a line. It shows the contract, the clients you can use, and what the sandbox blocks.
2. How your class gets its dependencies
Some problems run against real infrastructure: a Postgres database, a Redis server, or both. The problem page shows them as Recommended systems. You don't open connections yourself. You ask for a client in your constructor, and the grader passes one in. Parameters are matched by type:
public class ParkingLotImpl implements ParkingLotContract {
private final PostgresClient db;
public ParkingLotImpl(PostgresClient db) {
this.db = db;
db.execute("""
CREATE TABLE IF NOT EXISTS spots (
id BIGSERIAL PRIMARY KEY,
floor INT NOT NULL,
kind TEXT NOT NULL,
plate TEXT
)""");
}
}
A problem that needs both asks for both: public PipelineImpl(PostgresClient db, RedisClient redis). Problems marked kv-store need nothing: keep your state in memory.
⚠️ Trap:
DriverManager,DataSource, sockets andHttpClientare blocked. So are reflection, file I/O,Runtime.exec(),System.exit()andSystem.getenv(). Code that reaches for them fails before a single scenario runs.
Threads are allowed in LLD problems (unlike DSA problems). You will need them less often than you think, but you must expect the grader to use them against you.
3. Compile, then Submit
The editor has two buttons:
- Compile (
Ctrl+Enter) checks that your class builds against the contract. It's fast, and it's where missing methods and wrong signatures show up. - Submit (
Ctrl+Shift+Enter) runs the full grader. Progress streams in while it runs, and the result lands in the Submissions tab with a score breakdown. Your best score goes on the Leaderboard.
Compile often. Submit when you believe you're done, then read the breakdown, because it tells you where the points went.
Figure: What happens after you press Submit: compile, the graded scenarios, then the three score parts
- You press Submit; your class goes to an isolated runner.
- It compiles against the contract; a missing method or wrong signature stops here.
- The hidden scenarios run: happy paths, edge cases, errors, concurrency and invariants.
- A load test measures throughput, P99 latency and error rate.
- By default the score is functional 40%, performance 40% and quality 20%.
4. What the grader actually tests
The graded scenarios stay hidden, but they always fall into the same families:
- Happy paths. The brief's main flows, one call at a time.
- Edge cases. Empty input, unknown ids, zero capacity, duplicates, the boundary of every limit the brief mentions.
- Errors. Some calls must fail. When the brief says an operation is invalid, the grader expects an exception (Java's
IllegalArgumentExceptionorIllegalStateExceptionare the usual choices) or the "not found" value the contract documents, such asnullorfalse. Silently doing nothing loses the point. - Concurrency. Many threads calling your object at once. The scenario then checks a count, a balance or an invariant that only holds if your code is thread-safe.
- Performance. A sustained load, with throughput, latency and error rate measured.
⚠️ Trap: Don't assume state from a previous test is still there, and don't assume it's gone either. Every operation should work on whatever the contract's own calls created.
5. How the score is built
Your score is a weighted mix of three numbers, each from 0 to 100:
| Part | What it measures | Default weight |
|---|---|---|
| Functional | The share of graded scenarios you pass | 40% |
| Performance | Throughput (40%), P99 latency (30%) and error rate (30%), each graded in tiers against the problem's targets | 40% |
| Quality | Static analysis of your source: size, branching complexity, error handling and naming | 20% |
A problem can set its own weights. Two things follow from the table:
- Correctness first. A fast solution that fails scenarios loses functional points, and it usually loses performance points too, because errors under load count against the error rate.
- Quality is measured, not judged by a person. Solutions between roughly 30 and 300 effective lines score best on size. Deeply nested branches cost points, and so do swallowed exceptions and names like
a,tmp2ordoIt.
✅ Success: A clean, correct, thread-safe solution with no clever tricks usually scores higher than a hand-tuned one with a subtle race.
6. Learning aids on the problem page
- The Description tab has the brief, the constraints and, for many problems, a Walkthrough card linking to a full blog post on that problem.
- Some problems have a Visualize tab that steps through worked examples of a correct solution.
- The AI tutor in the sidebar knows which problem you're on and can explain the brief, the contract and those examples.
None of these show the graded scenarios. They teach the idea and leave the edge cases to you.
7. A routine that works
- Read the brief twice. Write down every rule it states, especially the ones phrased as "must not".
- Read the contract. For each method, decide what it returns on success, on "not found" and on invalid input.
- Pick your state: in-memory structures, Redis keys or Postgres tables.
- Decide where concurrency can bite, and how you'll prevent it.
- Write the simplest correct version. Compile. Submit.
- Read the breakdown, fix the biggest loss, and submit again.
Takeaways
- The grader is a demanding caller, not a reviewer: it runs your code sequentially, concurrently and under load.
- Ask for
PostgresClientorRedisClientin your constructor, and never open your own connections. - Correctness and thread-safety drive most of the score. Quality and speed come after.
Try it yourself: start with an easy one, such as Build a Retry Engine or Build an Employee Management System, and read the LLD roadmap for the order to take the rest.