Welcome to my LeetCode solutions repository! This repository is a curated, automatically synced collection of my accepted LeetCode solutions, organized by data structures and algorithms.
Unlike a flat list of files, this repository is organized by Topic Tags to make it easier to track progress and review specific concepts.
Every problem folder contains:
README.md— The full problem description, examples, and constraints (auto-generated).solution.ext— My accepted solution code in the language I solved it in.notes.md— My personal notes on intuition, approach, time/space complexity, and mistakes.
LeetCode/
│
├── Arrays/
│ └── 0001 Two Sum/
│ ├── README.md
│ ├── solution.py
│ └── notes.md
│
├── Linked List/
│ └── 0206 Reverse Linked List/
│ ├── README.md
│ ├── solution.py
│ └── notes.md
│
├── Trees/
├── Graphs/
└── Dynamic Programming/
This repository is maintained entirely by a custom GitHub Action—no browser extensions required!
Every day, a Python script runs on GitHub's servers that:
- Connects to the LeetCode GraphQL API.
- Fetches my most recent accepted submissions.
- Retrieves problem metadata (title, difficulty, description, constraints) and the exact code I submitted.
- Automatically creates the topic folder and problem folder.
- Generates the
README.mdand anotes.mdtemplate. - Makes one git commit per solved problem and pushes them.
Each solution is committed with its actual LeetCode solve time as the commit date — so the contribution graph reflects the day a problem was actually solved, even if the sync ran hours later. Commit messages look like:
solve: 0240 Search a 2D Matrix II (cpp)
Because the script checks for existing folders, it never overwrites my personal notes.md once I've written in them.
The sync runs every 6 hours (00:00, 06:00, 12:00, 18:00 UTC) so solutions land in the repo the same day they're solved.
The LEETCODE_SESSION cookie LeetCode gives your browser lives for a few weeks (typically 2–6). When it expires, the script fails loudly with a red run and a failure email instead of silently syncing nothing. Two things you may see:
FAILED: LEETCODE_SESSION cookie is expired or invalidat the session-verification step, orLeetCode returned empty code for submission ...— LeetCode shows your submission list publicly, but the code is only readable with a valid session.
Either way the fix is the same ~2-minute routine:
- Log in to LeetCode in your browser.
- Open DevTools → Application → Cookies →
https://leetcode.com. - Copy the value of the
LEETCODE_SESSIONcookie. - Update the secret at Settings → Secrets and variables → Actions → LEETCODE_SESSION.
- Re-run the workflow from the Actions tab (or wait for the next scheduled run).
Missed solves are picked up automatically as long as they're within the ~50 most recent submissions; older ones can be recovered by re-submitting them on LeetCode. Late backfills are committed with their original solve dates, so they land on the right day of the contribution graph.
Note: a green run with no new commits means there were genuinely no new accepted submissions to sync — the script can no longer "succeed" while actually failing, so green + no commit is always a non-event.
- I solve problems directly on LeetCode.
- The GitHub Action automatically syncs the solution and problem statement here.
- I periodically pull the changes locally and fill out the
notes.mdtemplate with my thought process, time/space complexity, and edge cases I might have missed.
Last synced automatically via GitHub Actions.