Skip to content

Commit d9b3ed8

Browse files
committed
feat(leetcode): solve 11 - Container With Most Water
1 parent 950e447 commit d9b3ed8

11 files changed

Lines changed: 356 additions & 71 deletions

File tree

.env

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
LEETCODE_SESSION=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfYXV0aF91c2VyX2lkIjoiMTI5ODI3MzMiLCJfYXV0aF91c2VyX2JhY2tlbmQiOiJhbGxhdXRoLmFjY291bnQuYXV0aF9iYWNrZW5kcy5BdXRoZW50aWNhdGlvbkJhY2tlbmQiLCJfYXV0aF91c2VyX2hhc2giOiI4NGE5ZTQ0YmU0ZWQ3NjQzOThmNWMwZjBkZDViOGE4ZGZkOWZmYjE5Njg2YTNlMWZmZTE4OTZhMmMyOTQ5YTBiIiwic2Vzc2lvbl91dWlkIjoiMjg2ODI2ZDYiLCJpZCI6MTI5ODI3MzMsImVtYWlsIjoicmFqamFybmF2QGdtYWlsLmNvbSIsInVzZXJuYW1lIjoicmFqamFybmF2IiwidXNlcl9zbHVnIjoicmFqamFybmF2IiwiYXZhdGFyIjoiaHR0cHM6Ly9hc3NldHMubGVldGNvZGUuY29tL3VzZXJzL3Jhamphcm5hdi9hdmF0YXJfMTc0MDQxMTAzMy5wbmciLCJyZWZyZXNoZWRfYXQiOjE3ODI4NzY4MzYsImlwIjoiMjQwOTo0MGU0OjZlOjUwNTI6NzBhNDoyODc3OmYxOWM6ZGE3OSIsImlkZW50aXR5IjoiMTZmZWUzNzU1OWRiZDQyYjQ0ODIwNDQ0NmQwMjA4OWYiLCJkZXZpY2Vfd2l0aF9pcCI6WyJjYTc3MWEzNmNhNjA5NzJhYjA4NzU1ZWVlMDA3MzUzZCIsIjI0MDk6NDBlNDo2ZTo1MDUyOjcwYTQ6Mjg3NzpmMTljOmRhNzkiXX0.yZNj861870yrKRZQ5WxoFO336W29dcX0ZkbNlp0bkWc
2-
1+
LEETCODE_SESSION=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfYXV0aF91c2VyX2lkIjoiMTI5ODI3MzMiLCJfYXV0aF91c2VyX2JhY2tlbmQiOiJhbGxhdXRoLmFjY291bnQuYXV0aF9iYWNrZW5kcy5BdXRoZW50aWNhdGlvbkJhY2tlbmQiLCJfYXV0aF91c2VyX2hhc2giOiI4NGE5ZTQ0YmU0ZWQ3NjQzOThmNWMwZjBkZDViOGE4ZGZkOWZmYjE5Njg2YTNlMWZmZTE4OTZhMmMyOTQ5YTBiIiwic2Vzc2lvbl91dWlkIjoiMjg2ODI2ZDYiLCJpZCI6MTI5ODI3MzMsImVtYWlsIjoicmFqamFybmF2QGdtYWlsLmNvbSIsInVzZXJuYW1lIjoiYXJuYXYtb24tY29kZSIsInVzZXJfc2x1ZyI6ImFybmF2LW9uLWNvZGUiLCJhdmF0YXIiOiJodHRwczovL2Fzc2V0cy5sZWV0Y29kZS5jb20vdXNlcnMvcmFqamFybmF2L2F2YXRhcl8xNzQwNDExMDMzLnBuZyIsInJlZnJlc2hlZF9hdCI6MTc4Mjg3NjgzNiwiaXAiOiIyNDA5OjQwZTU6OWQ6YjQzNToyNDJhOmI5Yzg6NTI3YzpiMWViIiwiaWRlbnRpdHkiOiIxNmZlZTM3NTU5ZGJkNDJiNDQ4MjA0NDQ2ZDAyMDg5ZiIsImRldmljZV93aXRoX2lwIjpbImNhNzcxYTM2Y2E2MDk3MmFiMDg3NTVlZWUwMDczNTNkIiwiMjQwOTo0MGU1OjlkOmI0MzU6MjQyYTpiOWM4OjUyN2M6YjFlYiJdfQ.WKOZnp3YlQpZRxpozUTXKSEcLhPZkxLYned_siaYLSQ
32
CSRF_TOKEN=eKyI0IvuBIkDJBAYY7T2rsaSv5KNMEJn
4-
53
GIT_USERNAME=arnav-on-code
6-
74
GIT_EMAIL= rajjarnav@gmail.com
8-
95
LEETCODE_USERNAME= arnav-on-code

README.md

Lines changed: 66 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,73 @@
1-
# LeetCode Sync
1+
# 🚀 LeetCode Sync
22

3-
A Python-based automation tool that synchronizes accepted LeetCode solutions to GitHub without relying on third-party browser extensions.
3+
Automatically synchronize accepted LeetCode submissions to GitHub.
44

5-
## Objective
5+
---
66

7-
This project aims to build a secure and customizable alternative to browser extensions by automating the entire workflow—from fetching accepted LeetCode submissions to committing and pushing them to a GitHub repository.
7+
## 📈 Progress
88

9-
## Planned Features
9+
```text
10+
████████████░░░░░░░░░░░░░░░░░░
1011
11-
* Fetch accepted LeetCode submissions
12-
* Download submitted source code
13-
* Organize solutions by problem number and title
14-
* Automatically generate and update a README
15-
* Commit and push new solutions to GitHub
16-
* Scheduled synchronization using GitHub Actions
17-
* Logging and error handling
18-
* Modular and extensible project architecture
19-
* Unit tests for core components
12+
Solved: 121 / 300 Problems
2013
21-
## Project Structure
14+
📊 Statistics
15+
Difficulty Solved
16+
🟢 Easy 63
17+
🟡 Medium 52
18+
🔴 Hard 6
19+
Total 121
20+
🔥 Latest Accepted Problem
2221
23-
```text
24-
leetcode-sync/
25-
26-
├── README.md
27-
├── requirements.txt
28-
├── .env.example
29-
├── config.py
30-
├── main.py
31-
32-
├── leetcode/
33-
├── github_sync/
34-
├── storage/
35-
├── logs/
36-
├── tests/
37-
└── .github/
38-
└── workflows/
39-
```
40-
41-
## Tech Stack
42-
43-
* Python
44-
* Git
45-
* GitHub Actions
46-
* Requests
47-
* BeautifulSoup
48-
* GitPython
49-
* python-dotenv
50-
* Pytest
51-
52-
## Project Status
53-
54-
🚧 This project is currently under active development.
55-
56-
The first milestone focuses on setting up the project structure before implementing LeetCode authentication, solution synchronization, Git automation, and scheduled workflows.
57-
58-
## License
59-
60-
This project is intended for educational and personal use.
22+
23+
| Field | Value |
24+
|------|------|
25+
| Problem ID | 11 |
26+
| Title | Container With Most Water |
27+
| Language | Python3 |
28+
| Runtime | 64 ms |
29+
| Memory | 29.5 MB |
30+
31+
32+
💻 Languages Used
33+
34+
- **Python3** : 1
35+
36+
✨ Features
37+
Automatic LeetCode synchronization
38+
Automatic Git commits
39+
Automatic GitHub push
40+
Metadata generation
41+
README generation
42+
GitHub Actions support
43+
Unit tests
44+
📂 Repository Structure
45+
storage/
46+
└── solutions/
47+
├── 0011_Container_With_Most_Water/
48+
│ ├── solution.py
49+
│ └── metadata.json
50+
└── ....
51+
⚙️ Workflow
52+
LeetCode
53+
54+
55+
API
56+
57+
58+
Downloader
59+
60+
61+
Statistics
62+
63+
64+
README Generator
65+
66+
67+
Git
68+
69+
70+
GitHub
71+
⏰ Last Sync
72+
73+
2026-07-02T09:32:10.126675

github_sync/commit.py

Whitespace-only changes.

github_sync/git.py

Whitespace-only changes.

github_sync/manager.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,26 @@ class GitManager:
1010

1111
def __init__(self, repository: Path):
1212
if shutil.which("git") is None:
13-
raise RuntimeError("Git is not installed or not available in PATH.")
13+
raise RuntimeError(
14+
"Git is not installed or not available in PATH."
15+
)
1416

1517
self.repository = Path(repository).resolve()
1618

19+
def sync(self, commit_message: str) -> None:
20+
"""
21+
Stage, commit and push all changes.
22+
"""
23+
24+
self.add()
25+
26+
if not self.status():
27+
print("No changes to commit.")
28+
return
29+
30+
self.commit(commit_message)
31+
self.push()
32+
1733
def run(self, *args: str) -> str:
1834
try:
1935
result = subprocess.run(
@@ -42,4 +58,4 @@ def push(self) -> None:
4258
self.run("push")
4359

4460
def pull(self) -> None:
45-
self.run("pull")
61+
self.run("pull")

github_sync/readme.py

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
from pathlib import Path
2+
3+
from config.settings import Config
4+
5+
6+
class ReadmeGenerator:
7+
"""
8+
Generates the project's README.md automatically.
9+
"""
10+
11+
def __init__(self):
12+
self.readme = Config.BASE_DIR / "README.md"
13+
14+
@staticmethod
15+
def progress_bar(current: int, total: int = 300, width: int = 30) -> str:
16+
"""
17+
Generate a unicode progress bar.
18+
"""
19+
filled = int((current / total) * width)
20+
filled = min(filled, width)
21+
22+
return "█" * filled + "░" * (width - filled)
23+
24+
def generate(self, stats) -> Path:
25+
"""
26+
Generate README.md from statistics.
27+
"""
28+
29+
latest = stats.get("last_problem")
30+
31+
# ---------- Languages ----------
32+
language_lines = []
33+
34+
for language, count in sorted(
35+
stats["languages"].items(),
36+
key=lambda item: item[1],
37+
reverse=True,
38+
):
39+
language_lines.append(f"- **{language}** : {count}")
40+
41+
languages = "\n".join(language_lines)
42+
43+
# ---------- Latest Problem ----------
44+
if latest:
45+
latest_problem = f"""
46+
| Field | Value |
47+
|------|------|
48+
| Problem ID | {latest["id"]} |
49+
| Title | {latest["title"]} |
50+
| Language | {latest["language"]} |
51+
| Runtime | {latest["runtime"]} |
52+
| Memory | {latest["memory"]} |
53+
"""
54+
else:
55+
latest_problem = "No submissions yet."
56+
57+
progress = self.progress_bar(stats["total"])
58+
59+
content = f"""# 🚀 LeetCode Sync
60+
61+
Automatically synchronize accepted LeetCode submissions to GitHub.
62+
63+
---
64+
65+
## 📈 Progress
66+
67+
```text
68+
{progress}
69+
70+
Solved: {stats["total"]} / 300 Problems
71+
72+
📊 Statistics
73+
Difficulty Solved
74+
🟢 Easy {stats["easy"]}
75+
🟡 Medium {stats["medium"]}
76+
🔴 Hard {stats["hard"]}
77+
Total {stats["total"]}
78+
🔥 Latest Accepted Problem
79+
80+
{latest_problem}
81+
82+
💻 Languages Used
83+
84+
{languages}
85+
86+
✨ Features
87+
Automatic LeetCode synchronization
88+
Automatic Git commits
89+
Automatic GitHub push
90+
Metadata generation
91+
README generation
92+
GitHub Actions support
93+
Unit tests
94+
📂 Repository Structure
95+
storage/
96+
└── solutions/
97+
├── 0011_Container_With_Most_Water/
98+
│ ├── solution.py
99+
│ └── metadata.json
100+
└── ....
101+
⚙️ Workflow
102+
LeetCode
103+
104+
105+
API
106+
107+
108+
Downloader
109+
110+
111+
Statistics
112+
113+
114+
README Generator
115+
116+
117+
Git
118+
119+
120+
GitHub
121+
⏰ Last Sync
122+
123+
{stats["last_sync"]}
124+
"""
125+
126+
self.readme.write_text(
127+
content,
128+
encoding="utf-8",
129+
)
130+
131+
return self.readme

0 commit comments

Comments
 (0)