> ## Documentation Index
> Fetch the complete documentation index at: https://leetcode-py.wisl.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> leetcode-py is a Python LeetCode practice environment generator with one CLI: lcpy. It is not a service or platform.
> Each problem is a directory under leetcode/ with README.md, solution.py, test_solution.py, helpers.py, and playground.ipynb. lcpy gen creates them from JSON templates bundled with the package.
> Examples are backed by tests; copy them verbatim.

# Notebooks

> Every problem ships a playground in jupytext percent format, plain Python in git and a notebook when you want one.

Every problem directory includes `playground.py`, a scratchpad for poking
at inputs, inspecting data structures, and experimenting before you commit
to an approach. See [Problem Anatomy](/practice/problem-anatomy) for where
it fits.

## Percent format, not .ipynb

Playgrounds are stored as jupytext **percent format**: plain Python with
`# %%` cell markers.

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
# %%
from helpers import assert_two_sum, run_two_sum
from solution import Solution

# %%
# Example test case
nums = [2, 7, 11, 15]
target = 9
expected = [0, 1]

# %%
result = run_two_sum(Solution, nums, target)
result

# %%
assert_two_sum(result, expected)
```

In git that means clean diffs, real code review, and mergeable history,
with none of the JSON noise `.ipynb` would add.

## Open it as a notebook

Pick whichever fits your setup:

* **VS Code**: the Python extension supports `# %%` cells natively; open
  `playground.py` and run cells in the interactive window.
* **JupyterLab with the jupytext contents manager**: same experience, in
  the browser.
* **One-off conversion**: `uv run jupytext --to ipynb
  leetcode/two_sum/playground.py` gives you a real `playground.ipynb`.

<img src="https://mintcdn.com/leetcode-py/VCrzlUI648LnF7Pk/images/notebook-example.png?fit=max&auto=format&n=VCrzlUI648LnF7Pk&q=85&s=bbcfff1fc08783d4daf7a6e91eb77eb8" alt="playground.py open as a notebook with executed cells" width="1156" height="908" data-path="images/notebook-example.png" />

## Convert back before committing

If you converted to `.ipynb`, convert back before you commit. The repo
keeps only the `.py` form:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
bake nb-to-py   # all .ipynb under leetcode/ -> py:percent, .ipynb deleted
```

## A scratchpad, not the contract

The playground imports the same helpers and solution as the tests, so what
you probe here matches what the suite runs. Nothing in it is graded;
[test\_solution.py](/practice/testing) stays the contract.
