Skip to content
Draft
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
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
env/
venv/
.venv/

# Temporary files
*.tmp
*.temp
.DS_Store
Thumbs.db

# IDE files
.vscode/
.idea/
*.swp
*.swo

# Build artifacts
*.class
*.exe
*.o
*.out
a.out

# Test files
test*
temp*
83 changes: 83 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# πŸ“ Changelog

All notable changes to this LeetCode solutions repository will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## πŸš€ How to View Changes

You can view changes in several ways:

### Using the Change Viewer Script
```bash
# View recent changes (last 7 days)
python3 view_changes.py

# View changes from last 30 days
python3 view_changes.py --recent 30

# Show solution statistics
python3 view_changes.py --stats

# List all solutions
python3 view_changes.py --list

# View change history for a specific file
python3 view_changes.py --file "Solutions/121. Best Time to Buy and Sell Stock.java"
```

### Using Git Commands
```bash
# View recent commits
git log --oneline -10

# View changes in the last week
git log --since="1 week ago" --oneline

# View detailed changes for a specific file
git log -p -- "Solutions/filename.java"

# See what files were changed in recent commits
git log --name-only --oneline -5
```

---

## [Unreleased]

### Added
- πŸ“œ `view_changes.py` - Interactive script to view repository changes
- πŸ“ `CHANGELOG.md` - This changelog file to track all changes
- πŸ” Enhanced documentation for viewing changes

### Removed
- πŸ—‘οΈ Removed placeholder `blah` file from Solutions directory

---

## [2025-09-08] - Repository Enhancement

### Added
- πŸ–ΌοΈ Added contribution snake animation to README
- πŸ“š Enhanced README with better usage instructions
- β˜• **121. Best Time to Buy and Sell Stock** - Java solution with comments
- πŸ’» **1342. Number of Steps to Reduce a Number to Zero** - C++ solution
- πŸ’» **1672. Richest Customer Wealth** - C++ solution
- πŸ’» **412. Fizz Buzz** - C++ solution
- β˜• **42. Trapping Rain Water** - Java solution with detailed logic

### Changed
- πŸ“– Updated README with comprehensive usage guide
- 🎯 Added clear goals and learning objectives
- πŸ“¬ Added contact information and social links

---

## Legend
- β˜• Java solutions
- πŸ’» C++ solutions
- 🐍 Python solutions
- πŸ“š Documentation updates
- πŸ”§ Tools and utilities
- πŸ› Bug fixes
- πŸ—‘οΈ Removals
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@ This repository contains all of my **LeetCode problem solutions**, stored in a s
- File names usually match the problem title (underscores instead of spaces).
- Use the search bar on GitHub to quickly find a problem by name.

## πŸ“ˆ View Changes & Track Progress
Want to see what's new or track your progress? Use the built-in change viewer:

```bash
# View recent changes (last 7 days)
python3 view_changes.py

# View changes from last 30 days
python3 view_changes.py --recent 30

# Show solution statistics
python3 view_changes.py --stats

# List all solutions
python3 view_changes.py --list
```

You can also check the **`CHANGELOG.md`** file for a detailed history of all additions and updates! πŸ“


## πŸ› οΈ Languages Used

Expand Down
1 change: 0 additions & 1 deletion Solutions/blah

This file was deleted.

5 changes: 5 additions & 0 deletions view-changes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
# LeetCode Solutions Change Viewer - Shell wrapper
# Usage: ./view-changes.sh [options]

python3 view_changes.py "$@"
129 changes: 129 additions & 0 deletions view_changes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
#!/usr/bin/env python3
"""
LeetCode Solutions Change Viewer
Helps track and view changes to your LeetCode solutions repository.
"""

import subprocess
import os
import sys
from datetime import datetime, timedelta
import argparse

def run_git_command(command):
"""Run a git command and return the output."""
try:
result = subprocess.run(command, shell=True, capture_output=True, text=True, cwd=os.getcwd())
return result.stdout.strip() if result.returncode == 0 else None
except Exception as e:
print(f"Error running command: {e}")
return None

def get_recent_changes(days=7):
"""Get recent changes in the last N days."""
since_date = (datetime.now() - timedelta(days=days)).strftime('%Y-%m-%d')
cmd = f'git log --since="{since_date}" --pretty=format:"%h|%ad|%s" --date=short --name-only'
output = run_git_command(cmd)

if not output:
print(f"No changes found in the last {days} days.")
return

print(f"πŸ“… Changes in the last {days} days:\n")

lines = output.split('\n')
current_commit = None

for line in lines:
if '|' in line: # This is a commit line
parts = line.split('|')
hash_val, date, message = parts[0], parts[1], parts[2]
current_commit = hash_val
print(f"πŸ”Έ {date} [{hash_val}] {message}")
elif line.strip() and not line.startswith(' '): # This is a file name
if line.startswith('Solutions/'):
print(f" πŸ“ {line}")
else:
print(f" πŸ“„ {line}")
print()

def get_solution_stats():
"""Get statistics about solutions."""
java_count = run_git_command('find Solutions -name "*.java" | wc -l')
cpp_count = run_git_command('find Solutions -name "*.cpp" | wc -l')
py_count = run_git_command('find Solutions -name "*.py" | wc -l')

print("πŸ“Š Solution Statistics:")
print(f" β˜• Java solutions: {java_count or 0}")
print(f" πŸ’» C++ solutions: {cpp_count or 0}")
print(f" 🐍 Python solutions: {py_count or 0}")
print(f" πŸ“ Total solutions: {int(java_count or 0) + int(cpp_count or 0) + int(py_count or 0)}")
print()

def show_file_changes(filename):
"""Show changes to a specific file."""
cmd = f'git log --follow -p -- "{filename}"'
output = run_git_command(cmd)

if not output:
print(f"No changes found for {filename}")
return

print(f"πŸ“œ Change history for {filename}:\n")
print(output)

def list_solutions():
"""List all available solutions."""
cmd = 'find Solutions -name "*.java" -o -name "*.cpp" -o -name "*.py" | sort'
output = run_git_command(cmd)

if not output:
print("No solutions found.")
return

print("πŸ“š Available Solutions:\n")
for file in output.split('\n'):
if file.strip():
# Extract problem number and name from filename
basename = os.path.basename(file)
name_without_ext = os.path.splitext(basename)[0]
ext = os.path.splitext(basename)[1]

# Get language emoji
lang_emoji = "β˜•" if ext == ".java" else "πŸ’»" if ext == ".cpp" else "🐍"

print(f" {lang_emoji} {name_without_ext}")
print()

def main():
parser = argparse.ArgumentParser(description='View changes in your LeetCode solutions repository')
parser.add_argument('--recent', '-r', type=int, default=7,
help='Show changes from the last N days (default: 7)')
parser.add_argument('--stats', '-s', action='store_true',
help='Show solution statistics')
parser.add_argument('--list', '-l', action='store_true',
help='List all solutions')
parser.add_argument('--file', '-f', type=str,
help='Show change history for a specific file')

args = parser.parse_args()

print("πŸš€ LeetCode Solutions Change Viewer\n")

# Check if we're in a git repository
if not run_git_command('git rev-parse --git-dir'):
print("❌ Error: Not in a git repository")
sys.exit(1)

if args.file:
show_file_changes(args.file)
elif args.list:
list_solutions()
elif args.stats:
get_solution_stats()
else:
get_recent_changes(args.recent)
get_solution_stats()

if __name__ == "__main__":
main()