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:

  1. A brief. A real system in a few paragraphs: a parking lot, a rate limiter, a deployment pipeline.
  2. A contract. A Java interface (or the equivalent in Python, Go or Node). It's the only thing the grader talks to.
  3. 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 and HttpClient are blocked. So are reflection, file I/O, Runtime.exec(), System.exit() and System.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 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

4. What the grader actually tests

The graded scenarios stay hidden, but they always fall into the same families:

⚠️ 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:

PartWhat it measuresDefault weight
FunctionalThe share of graded scenarios you pass40%
PerformanceThroughput (40%), P99 latency (30%) and error rate (30%), each graded in tiers against the problem's targets40%
QualityStatic analysis of your source: size, branching complexity, error handling and naming20%

A problem can set its own weights. Two things follow from the table:

  1. 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.
  2. 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, tmp2 or doIt.

✅ 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

None of these show the graded scenarios. They teach the idea and leave the edge cases to you.

7. A routine that works

  1. Read the brief twice. Write down every rule it states, especially the ones phrased as "must not".
  2. Read the contract. For each method, decide what it returns on success, on "not found" and on invalid input.
  3. Pick your state: in-memory structures, Redis keys or Postgres tables.
  4. Decide where concurrency can bite, and how you'll prevent it.
  5. Write the simplest correct version. Compile. Submit.
  6. Read the breakdown, fix the biggest loss, and submit again.

Takeaways

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.