Skip to content

Commit 44960b8

Browse files
committed
organise with github actions
0 parents  commit 44960b8

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

.github/workflows/organise.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Organize LeetCode Solutions
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
organize:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repo
14+
uses: actions/checkout@v3
15+
16+
- name: Organize files
17+
run: |
18+
mkdir -p BinarySearch Arrays Strings LinkedList Stack Queue HashTable Trees Graphs DynamicProgramming Greedy Backtracking Recursion SlidingWindow TwoPointers Heap Trie UnionFind BitManipulation Math PrefixSum Sorting BFS DFS
19+
20+
for file in *.java; do
21+
content=$(cat "$file" | tr '[:upper:]' '[:lower:]')
22+
23+
if echo "$content" | grep -q "binary search"; then
24+
cp "$file" BinarySearch/
25+
elif echo "$content" | grep -q "sliding window"; then
26+
cp "$file" SlidingWindow/
27+
elif echo "$content" | grep -q "two pointers"; then
28+
cp "$file" TwoPointers/
29+
elif echo "$content" | grep -q "dynamic programming"; then
30+
cp "$file" DynamicProgramming/
31+
elif echo "$content" | grep -q "backtracking"; then
32+
cp "$file" Backtracking/
33+
elif echo "$content" | grep -q "recursion"; then
34+
cp "$file" Recursion/
35+
elif echo "$content" | grep -q "greedy"; then
36+
cp "$file" Greedy/
37+
elif echo "$content" | grep -q "heap\|priority queue"; then
38+
cp "$file" Heap/
39+
elif echo "$content" | grep -q "trie"; then
40+
cp "$file" Trie/
41+
elif echo "$content" | grep -q "union find"; then
42+
cp "$file" UnionFind/
43+
elif echo "$content" | grep -q "bit manipulation"; then
44+
cp "$file" BitManipulation/
45+
elif echo "$content" | grep -q "prefix sum"; then
46+
cp "$file" PrefixSum/
47+
elif echo "$content" | grep -q "sorting"; then
48+
cp "$file" Sorting/
49+
elif echo "$content" | grep -q "graph"; then
50+
cp "$file" Graphs/
51+
elif echo "$content" | grep -q "bfs"; then
52+
cp "$file" BFS/
53+
elif echo "$content" | grep -q "dfs"; then
54+
cp "$file" DFS/
55+
elif echo "$content" | grep -q "tree"; then
56+
cp "$file" Trees/
57+
elif echo "$content" | grep -q "linked list"; then
58+
cp "$file" LinkedList/
59+
elif echo "$content" | grep -q "stack"; then
60+
cp "$file" Stack/
61+
elif echo "$content" | grep -q "queue"; then
62+
cp "$file" Queue/
63+
elif echo "$content" | grep -q "hash"; then
64+
cp "$file" HashTable/
65+
elif echo "$content" | grep -q "string"; then
66+
cp "$file" Strings/
67+
elif echo "$content" | grep -q "array"; then
68+
cp "$file" Arrays/
69+
elif echo "$content" | grep -q "math"; then
70+
cp "$file" Math/
71+
fi
72+
done
73+
74+
- name: Commit changes
75+
run: |
76+
git config --global user.name "github-actions"
77+
git config --global user.email "actions@github.com"
78+
git add .
79+
git commit -m "Auto organize LeetCode solutions by topic (copy mode)" || echo "No changes"
80+
git push

0 commit comments

Comments
 (0)