-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcreate_problem.sh
More file actions
executable file
·96 lines (74 loc) · 1.99 KB
/
create_problem.sh
File metadata and controls
executable file
·96 lines (74 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
# Script to create a new LeetCode problem folder with proper structure
# Usage: ./create_problem.sh <date> <problem_id> <title> <difficulty>
if [ $# -ne 4 ]; then
echo "Usage: $0 <date> <problem_id> <title> <difficulty>"
echo "Example: $0 2025-01-27 0001 TwoSum Easy"
exit 1
fi
DATE=$1
PROBLEM_ID=$2
TITLE=$3
DIFFICULTY=$4
# Create folder name
FOLDER_NAME="${DATE}-${PROBLEM_ID}-${TITLE}"
FOLDER_PATH="${DIFFICULTY}/${FOLDER_NAME}"
# Create directory
mkdir -p "$FOLDER_PATH"
# Create Java solution file
cat > "$FOLDER_PATH/solution.java" << EOF
// Solution for LeetCode Problem #${PROBLEM_ID}: ${TITLE}
// Date: ${DATE}
// Difficulty: ${DIFFICULTY}
// Language: Java
class Solution {
// TODO: Implement your solution here
}
EOF
# Create JavaScript solution file
cat > "$FOLDER_PATH/solution.js" << EOF
// Solution for LeetCode Problem #${PROBLEM_ID}: ${TITLE}
// Date: ${DATE}
// Difficulty: ${DIFFICULTY}
// Language: JavaScript
/**
* TODO: Add parameter types and return type
*/
var solution = function() {
// TODO: Implement your solution here
};
EOF
# Create explanation file
cat > "$FOLDER_PATH/explanation.md" << EOF
# ${TITLE} - Problem #${PROBLEM_ID}
## Problem Statement
<!-- Add problem statement here -->
## Examples
<!-- Add examples here -->
## Approach
<!-- Describe your approach here -->
## Complexity Analysis
- **Time Complexity**:
- **Space Complexity**:
## Key Insights
<!-- Add key insights here -->
## Alternative Approaches
<!-- List alternative approaches if any -->
## Solutions in Different Languages
### Java
\`\`\`java
// See solution.java
\`\`\`
### JavaScript
\`\`\`javascript
// See solution.js
\`\`\`
EOF
echo "✅ Created problem folder: $FOLDER_PATH"
echo "📁 Files created:"
echo " - $FOLDER_PATH/solution.java"
echo " - $FOLDER_PATH/solution.js"
echo " - $FOLDER_PATH/explanation.md"
echo ""
echo "📝 Don't forget to update README.md with the new problem entry!"
echo "🌍 Solutions are now available in Java and JavaScript!"