-
Notifications
You must be signed in to change notification settings - Fork 0
/
readme.sh
64 lines (51 loc) · 1.95 KB
/
readme.sh
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
#!/bin/bash
# https://gist.github.com/cdown/1163649#gistcomment-1639097
urlencode() {
# urlencode <string>
local LANG=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
*) printf '%%%02X' "'$c" ;;
esac
done
}
file="README.md"
rm $file
echo "# LeetCode
Author: [https://github.com/wang-chenxi](https://github.com/wang-chenxi)
My JS/Java Code for LeetCode.
The README is updated weekly.
Please give this repo a :star: if it inspires you. Thanks. :blush:
😩 Hate manually copy & pasting the example testcases when solving LeetCode problems?
👉 Try my husband Richard's [LeetCode Testcase Extractor](https://liuzhenglai.com/post/5e6f2551e9a0d01760b274d8)
Now I'm using a Chrome Extension Richard developed -- [LeetCoder](https://chrome.google.com/webstore/detail/gkmoalkjclphfhgnhdlilebaolpdkgpf) -- to facilitate my having fun on LeetCode. Features including but not limited to:
* showing stats
* copying problem, answer and **testcases**
* randomly picking a problem.
\# | Title | Difficulty | Solution
---|---|---|---" >> $file
IFS=$'\n'; for d in $(find leetcode/ -type d -maxdepth 1 -mindepth 1 -exec basename {} \; | sort -n) ; do # https://unix.stackexchange.com/questions/33909/list-files-sorted-numerically
num=$(echo "$d" | cut -d "." -f1)
title=$(echo "$d" | cut -d " " -f2-)
first=$(head -1 "leetcode/$d/README.md")
diff=""
case $first in
*\(Easy\)*)
diff="Easy"
;;
*\(Medium\)*)
diff="Medium"
;;
*\(Hard\)*)
diff="Hard"
;;
esac
line="$num | $title | $diff | [Solution](leetcode/$(urlencode $d))"
echo $line >> $file
done
echo "
# License
All rights reserved by [github.com/wang-chenxi](https://github.com/wang-chenxi). Contact me if you want to redistribute the code. No commercial use." >> $file