Skip to content

Commit 6e814a6

Browse files
committed
update: 添加问题“85.最大矩形”的代码和题解+ feat(hexo minify) (#1318) (#1319)
AC,100.00%,65.47% word: en(+jp) 2026.1.11 Signed-off-by: LetMeFly666 <Tisfy@qq.com>
1 parent e6562b7 commit 6e814a6

13 files changed

Lines changed: 401 additions & 30 deletions

.commitTitleExtra

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
+ feat(hexo minify) (#1318)

.commitmsg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
AC,100.00%,65.47%
2+
3+
word: en(+jp) 2026.1.11

.github/workflows/1problem1day-addNewIssue2project.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: Add issue & set Date
22+
id: add-issue-and-set-date
2223
env:
2324
GH_TOKEN: ${{ secrets.ONE_PROBLEM_ONE_DAY_PAT }}
2425
run: |
@@ -28,6 +29,7 @@ jobs:
2829
2930
if [[ ! "$title" =~ ^\[newSolution\]Who\ can\ add\ 1\ more\ problem\ of\ LeetCode\ [0-9]+.*$ ]]; then
3031
echo "Title not match, skip"
32+
echo "skip=true" >> $GITHUB_OUTPUT
3133
exit 0
3234
fi
3335
@@ -68,6 +70,7 @@ jobs:
6870
6971
- name: Resolve workflow path
7072
id: resolve-workflow-path
73+
if: steps.add-issue-and-set-date.outputs.skip != 'true'
7174
env:
7275
REPO: ${{ github.repository }}
7376
run: |
@@ -80,12 +83,14 @@ jobs:
8083
- name: Generate GitHub App token
8184
id: app-token
8285
uses: actions/create-github-app-token@v1
86+
if: steps.add-issue-and-set-date.outputs.skip != 'true'
8387
with:
8488
app-id: ${{ vars.DAILY_BOT_APP_ID }}
8589
private-key: ${{ secrets.DAILY_BOT_APP_PRIVATE_KEY }}
8690

8791
- name: Comment on issue
8892
uses: actions/github-script@v7
93+
if: steps.add-issue-and-set-date.outputs.skip != 'true'
8994
with:
9095
github-token: ${{ steps.app-token.outputs.token }}
9196
script: |

.github/workflows/deployHexo.yml

Lines changed: 146 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ on:
55
branches:
66
- master
77
- website_Static
8-
paths:
9-
- 'Solutions/**' # (#814)
8+
- website_testMaster
109

1110
env:
1211
GIT_USER: LetMeFly666
13-
GIT_EMAIL: 814114971@qq.com
12+
GIT_EMAIL: Tisfy@qq.com
1413

1514
jobs:
1615
build:
@@ -36,33 +35,73 @@ jobs:
3635
- name: Checkout this repo
3736
uses: actions/checkout@v3
3837
with:
38+
persist-credentials: true
3939
fetch-depth: 1
4040

41-
- name: Check for .nodeploy
41+
- name: Whether Skip Deploy(.nodeploy|filePath)
4242
id: deploy-check
4343
run: |
4444
if [ -f .nodeploy ]; then
45+
echo "Found .nodeploy, skip deploy"
4546
echo "SKIP_DEPLOY=true" >> $GITHUB_ENV
47+
exit 0
48+
fi
49+
50+
set -e
51+
echo "GITHUB_REF=$GITHUB_REF"
52+
echo "GITHUB_SHA=$GITHUB_SHA"
53+
echo "GITHUB_EVENT_BEFORE=${{ github.event.before }}"
54+
BRANCH="${GITHUB_REF#refs/heads/}"
55+
echo "Current branch: $BRANCH"
56+
57+
if [ "$BRANCH" = "website_Static" ]; then
58+
echo "website_Static branch, deploy"
59+
elif [ "$BRANCH" = "master" ] || [ "$BRANCH" = "website_testMaster" ]; then # (#814)、(#1318)
60+
echo "master branch, checking Solutions changes"
61+
git fetch --depth=2 origin "$BRANCH"
62+
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} $GITHUB_SHA || true)
63+
echo "Changed files:"
64+
echo "$CHANGED_FILES"
65+
if echo "$CHANGED_FILES" | grep -q '^Solutions/'; then
66+
echo "Solutions changed, deploy"
67+
else
68+
echo "No Solutions changes, skip deploy"
69+
echo "SKIP_DEPLOY=true" >> $GITHUB_ENV
70+
exit 0
71+
fi
4672
else
47-
echo "SKIP_DEPLOY=false" >> $GITHUB_ENV
73+
echo "Other branch ($BRANCH), skip deploy"
74+
echo "SKIP_DEPLOY=true" >> $GITHUB_ENV
75+
exit 0
4876
fi
4977
5078
- name: Fetch and checkout each branch (shallow)
5179
if: env.SKIP_DEPLOY != 'true'
5280
run: |
5381
# git clone git@github.com:LetMeFly666/LeetCode.git --depth=1
5482
# cd LeetCode
83+
# git rev-list --count HEAD
5584
git fetch --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
5685
for branch in $(git branch -r | grep -v '\->'); do
5786
local_branch="${branch#origin/}"
87+
if [[ "$local_branch" =~ ^[0-9] ]] || [[ "$local_branch" == "From_GitCode_CSDN" ]]; then
88+
echo "Skipping branch $local_branch"
89+
continue
90+
fi
5891
if ! git show-ref --quiet "refs/heads/$local_branch"; then
5992
echo "Setting branch $local_branch"
6093
git switch -c $local_branch origin/$local_branch
6194
else
6295
echo "Branch $local_branch already exists, skipping..."
6396
fi
6497
done
65-
git switch master
98+
99+
if [ "${GITHUB_REF}" = "refs/heads/website_testMaster" ]; then
100+
git switch website_testMaster
101+
else
102+
git switch master
103+
fi
104+
# git rev-list --count HEAD
66105
67106
- name: Use Node.js ${{ matrix.node_version }}
68107
if: env.SKIP_DEPLOY != 'true'
@@ -98,16 +137,7 @@ jobs:
98137
ssh-keyscan github.com >> ~/.ssh/known_hosts
99138
git config --global user.name $GIT_USER
100139
git config --global user.email $GIT_EMAIL
101-
102-
- name: Install hexo and init
103-
if: env.SKIP_DEPLOY != 'true'
104-
run: |
105-
npm install -g hexo-cli --save
106-
hexo init ../hexoWorkspace
107-
rm -f ../hexoWorkspace/source/_posts/hello-world.md # 不再显示Hello World这篇文章(每次都显示在首页)
108-
sed -i 's/"<em>" + text + "<\/em>"/"_" + text + "_"/g' ../hexoWorkspace/node_modules/marked/lib/*
109-
# cat ../hexoWorkspace/node_modules/marked/lib/*
110-
140+
111141
# 上次commit记录
112142
MESSAGE=$(git log -1 --format="%s")
113143
HASH=$(git log -1 --format="%H")
@@ -118,11 +148,104 @@ jobs:
118148
echo "$HASH"
119149
echo "MESSAGE=$MESSAGE" >> $GITHUB_ENV
120150
echo "HASH=$HASH" >> $GITHUB_ENV
151+
152+
- name: Checkout LastModifiedTime.json
153+
if: env.SKIP_DEPLOY != 'true'
154+
run: |
155+
git switch website_modifyTime
156+
cd ..
157+
cp -r LeetCode website_modifyTime
158+
cd LeetCode
159+
160+
if [ "${GITHUB_REF}" = "refs/heads/website_testMaster" ]; then
161+
git switch website_testMaster
162+
else
163+
git switch master
164+
fi
165+
166+
- name: Update LastModifiedTime.json
167+
if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/website_testMaster' ) && env.SKIP_DEPLOY != 'true'
168+
continue-on-error: false
169+
run: |
170+
set -e
171+
172+
json_file="../website_modifyTime/LastModifiedTime.json"
173+
174+
# 获取本次 push 里 master 分支变动的文件列表
175+
# TODO: Let's处理删除removed
176+
# TODO: Let's solve this
177+
echo '${{ toJSON(github.event) }}' | jq .
178+
changed_files=$(jq -r '
179+
[
180+
.commits[].added[]?,
181+
.commits[].modified[]?
182+
]
183+
| unique
184+
| .[]
185+
' "$GITHUB_EVENT_PATH")
186+
echo "Changed files:"
187+
echo "$changed_files"
188+
189+
# 保存原 json 内容顺序
190+
tmp_json=$(mktemp)
191+
cp "$json_file" "$tmp_json"
192+
193+
# 遍历每个文件,看是否是 Solutions 下的 md 文件
194+
updated=false
195+
commit_time=$(git show -s --format=%cI ${{ github.sha }}) # ISO 8601 commit 时间
196+
197+
while IFS= read -r file; do
198+
# 只处理 Solutions/*.md 文件
199+
if [[ "$file" == Solutions/*.md ]]; then
200+
filename=$(basename "$file")
201+
# 使用 jq 更新 JSON 值
202+
# 保持原有顺序,用临时文件写回
203+
jq --arg key "$filename" --arg value "$commit_time" '(.[$key] = $value) | .' "$tmp_json" > "$tmp_json.tmp" && mv "$tmp_json.tmp" "$tmp_json"
204+
updated=true
205+
fi
206+
done <<< "$changed_files"
207+
208+
if [ "$updated" != true ]; then
209+
echo "No Solutions/*.md file changed, skip JSON update."
210+
exit 0
211+
fi
212+
213+
# 提交修改
214+
cp "$tmp_json" "$json_file"
215+
cd ../website_modifyTime
216+
git add "$json_file"
217+
TOCOMMIT=$(printf "%s\n\n%s" "$MESSAGE" "$HASH")
218+
git commit --allow-empty -m "$TOCOMMIT"
219+
git push
220+
cd ../LeetCode
221+
222+
- name: Update Solutions/*.md file mtime
223+
if: env.SKIP_DEPLOY != 'true'
224+
run: |
225+
set -e
226+
227+
json_file="../website_modifyTime/LastModifiedTime.json"
228+
229+
while IFS= read -r line; do
230+
file_name=$(echo "$line" | jq -r 'keys[0]')
231+
file_time=$(echo "$line" | jq -r '.[keys[0]]')
232+
touch -d "$file_time" "Solutions/$file_name"
233+
echo "set Solutions/$file_name -> $file_time"
234+
done < <(jq -c 'to_entries | map({(.key): .value}) | .[]' "$json_file")
235+
236+
- name: Install hexo and init
237+
if: env.SKIP_DEPLOY != 'true'
238+
run: |
239+
npm install -g hexo-cli --save
240+
hexo init ../hexoWorkspace
241+
rm -f ../hexoWorkspace/source/_posts/hello-world.md # 不再显示Hello World这篇文章(每次都显示在首页)
242+
sed -i 's/"<em>" + text + "<\/em>"/"_" + text + "_"/g' ../hexoWorkspace/node_modules/marked/lib/*
243+
# cat ../hexoWorkspace/node_modules/marked/lib/*
121244
122245
- name: Copy config files from branch website_Static
123246
if: env.SKIP_DEPLOY != 'true'
124247
run: |
125-
cp -r Solutions ../Articles
248+
cp -a Solutions ../Articles
126249
127250
echo --- > ../Articles/README.md
128251
echo title: README >> ../Articles/README.md
@@ -141,7 +264,9 @@ jobs:
141264
# echo tree ../hexoWorkspace/source/_posts
142265
143266
# sub theme: 明日方舟arknights
144-
cp -r ../hexoWorkspace ../hexoWorkspace_arknights
267+
cp -a ../hexoWorkspace ../hexoWorkspace_arknights
268+
ls -l ../hexoWorkspace/source/_posts
269+
ls -l ../hexoWorkspace_arknights/source/_posts
145270
146271
- name: Install dependencies
147272
if: env.SKIP_DEPLOY != 'true'
@@ -188,6 +313,8 @@ jobs:
188313
- name: Modify sitemap
189314
if: env.SKIP_DEPLOY != 'true'
190315
run: |
316+
# TODO: Let's change this
317+
# TODO: Let's change tag orders
191318
echo "" > ../hexoWorkspace/public/sitemap.txt # 主站优先
192319
sed 's/theme\/arknights\///g' ../hexoWorkspace/public/theme/arknights/sitemap.txt >> ../hexoWorkspace/public/sitemap.txt
193320
cat ../hexoWorkspace/public/theme/arknights/sitemap.txt >> ../hexoWorkspace/public/sitemap.txt
@@ -253,6 +380,6 @@ jobs:
253380
# uses: EndBug/add-and-commit@v9
254381
# with:
255382
# author_name: LetMeFly
256-
# author_email: 814114971@qq.com
383+
# author_email: Tisfy@qq.com
257384
# message: "backup .deploy_git"
258385
# add: "."
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* @Author: LetMeFly
3+
* @Date: 2026-01-11 22:23:58
4+
* @LastEditors: LetMeFly.xyz
5+
* @LastEditTime: 2026-01-11 22:44:08
6+
*/
7+
#if defined(_WIN32) || defined(__APPLE__)
8+
#include "_[1,2]toVector.h"
9+
#endif
10+
11+
class Solution {
12+
public:
13+
int largestRectangleArea(vector<int>& heights) {
14+
stack<int> idx;
15+
heights.insert(heights.begin(), 0);
16+
heights.push_back(0);
17+
int ans = 0;
18+
for (int i = 0; i < heights.size(); i++) {
19+
while (idx.size() && heights[i] < heights[idx.top()]) {
20+
int lastIdx = idx.top();
21+
idx.pop();
22+
ans = max(ans, heights[lastIdx] * (i - idx.top() - 1));
23+
}
24+
idx.push(i);
25+
}
26+
return ans;
27+
}
28+
};

Codes/0085-maximal-rectangle.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* @Author: LetMeFly
3+
* @Date: 2026-01-11 22:47:21
4+
* @LastEditors: LetMeFly.xyz
5+
* @LastEditTime: 2026-01-11 23:13:41
6+
*/
7+
#if defined(_WIN32) || defined(__APPLE__)
8+
#include "_[1,2]toVector.h"
9+
#endif
10+
11+
class Solution {
12+
public:
13+
int maximalRectangle(vector<vector<char>>& matrix) {
14+
int ans = 0;
15+
vector<int> heights(matrix[0].size() + 2);
16+
for (int i = 0; i < matrix.size(); i++) {
17+
matrix[i].insert(matrix[i].begin(), '0');
18+
matrix[i].push_back('0');
19+
stack<int> st;
20+
for (int j = 0; j < matrix[i].size(); j++) {
21+
heights[j] = heights[j] && matrix[i][j] == '1' ? heights[j] + 1 : matrix[i][j] == '1';
22+
while (st.size() && heights[j] < heights[st.top()]) { // 记得st.size()也要判断,否则哨兵0会驱逐哨兵0
23+
int idx = st.top();
24+
st.pop();
25+
ans = max(ans, heights[idx] * (j - st.top() - 1));
26+
}
27+
st.push(j);
28+
}
29+
}
30+
return ans;
31+
}
32+
};

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@
190190
|0080.删除有序数组中的重复项II|中等|<a href="https://leetcode.cn/problems/remove-duplicates-from-sorted-array-ii/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2025/02/09/LeetCode%200080.%E5%88%A0%E9%99%A4%E6%9C%89%E5%BA%8F%E6%95%B0%E7%BB%84%E4%B8%AD%E7%9A%84%E9%87%8D%E5%A4%8D%E9%A1%B9II/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/145528267" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/remove-duplicates-from-sorted-array-ii/solutions/3068455/letmefly-80shan-chu-you-xu-shu-zu-zhong-b1e2i/" target="_blank">LeetCode题解</a>|
191191
|0082.删除排序链表中的重复元素II|中等|<a href="https://leetcode.cn/problems/remove-duplicates-from-sorted-list-ii/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2024/01/15/LeetCode%200082.%E5%88%A0%E9%99%A4%E6%8E%92%E5%BA%8F%E9%93%BE%E8%A1%A8%E4%B8%AD%E7%9A%84%E9%87%8D%E5%A4%8D%E5%85%83%E7%B4%A0II/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/135612345" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/remove-duplicates-from-sorted-list-ii/solutions/2605736/letmefly-82shan-chu-pai-xu-lian-biao-zho-92xm/" target="_blank">LeetCode题解</a>|
192192
|0083.删除排序链表中的重复元素|简单|<a href="https://leetcode.cn/problems/remove-duplicates-from-sorted-list/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2024/01/14/LeetCode%200083.%E5%88%A0%E9%99%A4%E6%8E%92%E5%BA%8F%E9%93%BE%E8%A1%A8%E4%B8%AD%E7%9A%84%E9%87%8D%E5%A4%8D%E5%85%83%E7%B4%A0/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/135581000" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/remove-duplicates-from-sorted-list/solutions/2603584/letmefly-83shan-chu-pai-xu-lian-biao-zho-cey8/" target="_blank">LeetCode题解</a>|
193+
|0085.最大矩形|困难|<a href="https://leetcode.cn/problems/maximal-rectangle/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2026/01/11/LeetCode%200085.%E6%9C%80%E5%A4%A7%E7%9F%A9%E5%BD%A2/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/156837504" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/maximal-rectangle/solutions/3878249/letmefly-85zui-da-ju-xing-dan-diao-zhan-xw9xw/" target="_blank">LeetCode题解</a>|
193194
|0086.分隔链表|中等|<a href="https://leetcode.cn/problems/partition-list/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2022/06/26/LeetCode%200086.%E5%88%86%E9%9A%94%E9%93%BE%E8%A1%A8/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/125467594" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/partition-list/solution/letmefly-86fen-ge-lian-biao-by-tisfy-64z3/" target="_blank">LeetCode题解</a>|
194195
|0088.合并两个有序数组|简单|<a href="https://leetcode.cn/problems/merge-sorted-array/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2023/08/13/LeetCode%200088.%E5%90%88%E5%B9%B6%E4%B8%A4%E4%B8%AA%E6%9C%89%E5%BA%8F%E6%95%B0%E7%BB%84/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/132256535" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/merge-sorted-array/solutions/2385633/letmefly-88he-bing-liang-ge-you-xu-shu-z-u9cc/" target="_blank">LeetCode题解</a>|
195196
|0090.子集II|中等|<a href="https://leetcode.cn/problems/subsets-ii/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2025/02/05/LeetCode%200090.%E5%AD%90%E9%9B%86II/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/145453136" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/subsets-ii/solutions/3064167/letmefly-90zi-ji-iier-jin-zhi-mei-ju-hui-y5mt/" target="_blank">LeetCode题解</a>|

0 commit comments

Comments
 (0)