-
Notifications
You must be signed in to change notification settings - Fork 0
Leetcode_problems: merge feat/upgrade into main #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7273e03
8d8f49b
3017918
74629c8
2cb3362
3b124a4
34148b5
8f55e4c
e2b65bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| 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 |
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| github: [aliammari1] |
| 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. --> |
| 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"] |
| 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 |
| 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[@]}" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: This Prompt for AI agents |
||
|
|
||
| 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 | ||
| 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' }} |
| 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 |
| 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 |
| 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$' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When this new CI job runs on the current repository, the exact command in this step fails immediately because many existing
solutions/**/Solution.cppfiles are not formatted with the new.clang-formatrules; I ran the samefind ... | clang-format --dry-run --Werrorblock and it reported thousands of violations, including accepted files such assolutions/diagonal-traverse/Accepted/8-26-2023, 10_44_24 AM/Solution.cppandsolutions/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 👍 / 👎.