Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# clang-format config for the C++ solution snippets.
# These are bare LeetCode editor bodies (no includes), so formatting is the only
# whole-file check that's meaningful; the syntax gate handles correctness.
BasedOnStyle: Google
IndentWidth: 4
TabWidth: 4
UseTab: Never
ColumnLimit: 100
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
SortIncludes: false
15 changes: 15 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# CodeRabbit config — lightweight, archive-appropriate.
language: en-US
reviews:
profile: chill
request_changes_workflow: false
high_level_summary: true
poem: false
review_status: true
path_filters:
- "!solutions/**" # don't nitpick historical submission snippets
- "scripts/**"
- ".github/**"
- "*.md"
chat:
auto_reply: true
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Keep LF for scripts and config so CI bash/Python behave identically on all OSes.
* text=auto eol=lf
*.png binary
*.jpg binary
*.svg text eol=lf
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [aliammari1]
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE/solution_issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: Solution issue
about: Report an incorrect solution or suggest an improvement
title: "[slug] short description"
labels: ["solution"]
---

**Problem slug:** <!-- e.g. two-sum (the directory name under solutions/) -->

**Language:** <!-- C++ / Java / Oracle SQL / MySQL -->

**What's wrong / what could be better?**

<!-- Note: failed-attempt snippets (Wrong Answer/Runtime Error/etc.) are kept on
purpose as part of the submission history; please don't report those as bugs. -->
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 2
# Archive repo: the only moving dependencies are GitHub Actions and the docs
# build tooling (requirements-docs.txt). Dependabot is the single dependency
# bot here — a Renovate config was removed to avoid duplicate update PRs.
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
commit-message:
prefix: "ci"
labels: ["dependencies"]
groups:
github-actions:
patterns: ["*"]

- package-ecosystem: pip
directory: "/"
schedule:
interval: weekly
commit-message:
prefix: "build"
labels: ["dependencies"]
62 changes: 62 additions & 0 deletions .github/workflows/ai-explain.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: AI solution explanations

on:
workflow_dispatch:
inputs:
limit:
description: "Max number of slugs to process (0 = all)"
default: "20"
force:
description: "Overwrite existing EXPLANATION.md"
type: boolean
default: false
schedule:
# Weekly top-up of any newly-added Accepted solutions lacking an explanation.
- cron: "0 5 * * 1"

permissions:
contents: write
pull-requests: write

jobs:
explain:
name: Generate EXPLANATION.md with Claude
runs-on: ubuntu-latest
# Gated: the job only runs when ANTHROPIC_API_KEY is configured.
if: ${{ vars.ENABLE_AI == 'true' || github.event_name == 'workflow_dispatch' }}
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install Anthropic SDK
run: pip install "anthropic>=0.40"

- name: Generate explanations (with WA/RE diff hook)
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
AI_MODEL: ${{ vars.AI_MODEL || 'claude-sonnet-4-6' }}
run: |
# Script is a no-op when ANTHROPIC_API_KEY is unset, so this is safe
# to run on PRs / forks without the secret.
ARGS="--tag --limit ${{ github.event.inputs.limit || '20' }}"
if [ "${{ github.event.inputs.force }}" = "true" ]; then ARGS="$ARGS --force"; fi
python scripts/ai_explain.py $ARGS

- name: Open PR with new explanations
if: ${{ env.HAS_KEY == 'true' }}
env:
HAS_KEY: ${{ secrets.ANTHROPIC_API_KEY != '' }}
uses: peter-evans/create-pull-request@v6
with:
commit-message: "docs: add AI-generated solution explanations"
title: "docs: AI solution explanations"
body: |
Auto-generated `EXPLANATION.md` files (approach, complexity, and a
diff vs the recorded Wrong-Answer / Runtime-Error attempts).
Review before merging.
branch: ai/explanations
add-paths: |
solutions/**/EXPLANATION.md
109 changes: 109 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: CI

on:
push:
branches: [main, master]
pull_request:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
progress:
name: Progress table is current
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
# Fails if README's PROGRESS block or docs/progress.json drifted from
# solutions/ — keeps the 173-vs-542 stats honest and reconciled.
- name: Check generated stats
run: python scripts/generate_progress.py --check

cpp-syntax:
name: C++ preamble-injection syntax gate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install g++
run: sudo apt-get update && sudo apt-get install -y g++
# Injects `#include <bits/stdc++.h>` + `using namespace std;` then runs
# g++ -fsyntax-only. Real errors fail the build (no `|| echo`).
- name: Syntax-check all Accepted C++ solutions
run: python scripts/compile_check.py --cxx g++ --std c++20

clang-format:
name: clang-format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: clang-format check (quoted globs)
run: |
# Paths contain spaces and commas — NUL-delimit and quote.
mapfile -d '' files < <(find solutions -type f -name 'Solution.cpp' -print0)
if [ ${#files[@]} -eq 0 ]; then echo "no C++ files"; exit 0; fi
clang-format --dry-run --Werror "${files[@]}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restrict clang-format or reformat existing snippets

When this new CI job runs on the current repository, the exact command in this step fails immediately because many existing solutions/**/Solution.cpp files are not formatted with the new .clang-format rules; I ran the same find ... | clang-format --dry-run --Werror block and it reported thousands of violations, including accepted files such as solutions/diagonal-traverse/Accepted/8-26-2023, 10_44_24 AM/Solution.cpp and solutions/robot-return-to-origin/Accepted/10-18-2023, 2_01_02 AM/Solution.cpp. Since the commit adds this workflow without reformatting or scoping it to changed/formatted files, every push/PR is blocked by pre-existing archive formatting rather than new changes.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: This clang-format --dry-run --Werror check runs against all existing Solution.cpp files, but the .clang-format config is newly introduced and existing files were never reformatted to match it. CI will fail on every push/PR due to pre-existing formatting violations in the archive. Either scope this to only changed files (e.g., using git diff --name-only filtered to .cpp), or reformat the existing files as part of this PR.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/ci.yml, line 55:

<comment>This `clang-format --dry-run --Werror` check runs against **all** existing `Solution.cpp` files, but the `.clang-format` config is newly introduced and existing files were never reformatted to match it. CI will fail on every push/PR due to pre-existing formatting violations in the archive. Either scope this to only changed files (e.g., using `git diff --name-only` filtered to `.cpp`), or reformat the existing files as part of this PR.</comment>

<file context>
@@ -0,0 +1,109 @@
+          # Paths contain spaces and commas — NUL-delimit and quote.
+          mapfile -d '' files < <(find solutions -type f -name 'Solution.cpp' -print0)
+          if [ ${#files[@]} -eq 0 ]; then echo "no C++ files"; exit 0; fi
+          clang-format --dry-run --Werror "${files[@]}"
+
+  cpp-linter:
</file context>


cpp-linter:
name: cpp-linter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cpp-linter/cpp-linter-action@v2
id: linter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
style: file
tidy-checks: "-*" # format-only; bare snippets have no compile DB
files-changed-only: false
extensions: cpp
- name: Fail on lint findings
if: steps.linter.outputs.checks-failed > 0
run: exit 1

sql:
name: sqlfluff (Oracle + MySQL)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install sqlfluff
run: pip install "sqlfluff==3.3.0"
- name: Lint Oracle SQL (quoted globs)
run: |
mapfile -d '' files < <(find solutions -type f -name '*.oraclesql' -print0)
if [ ${#files[@]} -eq 0 ]; then echo "no Oracle SQL"; exit 0; fi
sqlfluff lint --dialect oracle "${files[@]}"
- name: Lint MySQL (quoted globs)
run: |
mapfile -d '' files < <(find solutions -type f -name '*.mysql' -print0)
if [ ${#files[@]} -eq 0 ]; then echo "no MySQL"; exit 0; fi
sqlfluff lint --dialect mysql "${files[@]}"

docs:
name: mkdocs build (strict)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install docs deps
run: pip install -r requirements-docs.txt
- name: Generate pages
run: python scripts/generate_progress.py --docs
- name: Build
run: mkdocs build --strict
29 changes: 29 additions & 0 deletions .github/workflows/claude-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Claude PR review

on:
pull_request:
types: [opened, synchronize]
issue_comment:
types: [created]

permissions:
contents: read
pull-requests: write
issues: write

jobs:
review:
name: "@claude review"
runs-on: ubuntu-latest
# Gated on the secret: skips cleanly when ANTHROPIC_API_KEY is absent.
if: ${{ github.event_name == 'pull_request' || contains(github.event.comment.body, '@claude') }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Claude Code Action
uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
# Configurable; defaults to Sonnet for cost on an archive repo.
model: ${{ vars.AI_MODEL || 'claude-sonnet-4-6' }}
56 changes: 56 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Deploy docs (Cloudflare Pages)

on:
push:
branches: [main, master]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: docs-deploy
cancel-in-progress: true

jobs:
deploy:
name: Build & deploy to Cloudflare Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install docs deps
run: pip install -r requirements-docs.txt

- name: Generate per-slug pages
run: python scripts/generate_progress.py --docs

- name: Build site
run: mkdocs build --strict

# Gated: only deploys when the Cloudflare secrets are configured. On forks
# / PRs without them this whole step is skipped, so the workflow stays
# green without ever needing a CF account during development.
- name: Check Cloudflare secrets
id: cf
run: |
if [ -n "${{ secrets.CLOUDFLARE_API_TOKEN }}" ] && [ -n "${{ secrets.CLOUDFLARE_ACCOUNT_ID }}" ]; then
echo "enabled=true" >> "$GITHUB_OUTPUT"
else
echo "enabled=false" >> "$GITHUB_OUTPUT"
echo "::notice::Cloudflare secrets not set — skipping deploy (build verified only)."
fi

- name: Deploy to Cloudflare Pages
if: steps.cf.outputs.enabled == 'true'
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy site --project-name=leetcode-problems
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# mkdocs build output
/site/

# Generated docs pages (rebuilt by scripts/generate_progress.py --docs in CI;
# not committed to avoid churn). Only docs/progress.json is committed so the
# README's dynamic badges resolve without needing a docs build.
/docs/problems/
/docs/index.md
/docs/tags.md
/docs/lessons.md

# Python
__pycache__/
*.pyc
.venv/
venv/

# OS
.DS_Store
Thumbs.db

# Internal growth/marketing notes (not for public)
GROWTH.md
BANNER.md
SUBMITTING_TO_AWESOME.md
launch-kit.md
star-strategy.md
modernization-backlog.md
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Mirrors the CI gates locally. Install: pip install pre-commit && pre-commit install
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: end-of-file-fixer
exclude: '^solutions/'
- id: trailing-whitespace
exclude: '^solutions/'
- id: check-yaml

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.5
hooks:
- id: clang-format
files: '^solutions/.*Solution\.cpp$'

- repo: https://github.com/sqlfluff/sqlfluff
rev: 3.3.0
hooks:
- id: sqlfluff-lint
name: sqlfluff (oracle)
files: '\.oraclesql$'
args: ["--dialect", "oracle"]

- repo: local
hooks:
- id: progress-table
name: progress table up to date
entry: python scripts/generate_progress.py --check
language: system
pass_filenames: false
files: '^solutions/|^scripts/generate_progress\.py$'
Loading
Loading