Skip to content

Commit eb70d9b

Browse files
authored
update: 添加问题“960.删列造序III”的代码和题解 (#1274)
* feat: 1problem1day - comment by APP * 1problem1day: comment - 未测试 哎呀,重复代码越来越多了 * fix(+rename): duplicated repo name * 960: init.toMerge (#1272) lib.rs果然没有手动更改的必要 * 960: WA.cpp (#1272) * 960: AC.cpp+py+go + CE.java (#1272) cpp - AC,100.00%,60.81% py - AC,26.83%,100.00% go - AC,9.09%,100.00% go - AC,Resubmission,100.00%,100.00% CE.java * 960: AC.java+CE.rust (#1272) java - AC,87.23%,40.42% rust - 边搜边写 * 960: AC.rust (#1272) rust - AC,16.67%,33.33% * update: 添加问题“960.删列造序III”的代码和题解 (#1274) Signed-off-by: LetMeFly666 <[email protected]> --------- Signed-off-by: LetMeFly666 <[email protected]>
1 parent 5e1bd3e commit eb70d9b

20 files changed

+520
-30
lines changed

.commitmsg

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/workflows/1problem1day-addNewIssue.yml renamed to .github/workflows/1problem1day-addNewIssue2project.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Add issue to 1problem1day project
1+
name: Daily / Add issue to 1problem1day project
22
# 符合标题格式的issue自动添加到https://github.com/users/LetMeFly666/projects/5中
33
# Test at https://github.com/LetMeFly666/LeetCode-test
44

@@ -65,3 +65,40 @@ jobs:
6565
-f item="$item_id" \
6666
-f field="$DATE_FIELD_ID" \
6767
-f date="$date_cn"
68+
69+
- name: Resolve workflow path
70+
id: resolve-workflow-path
71+
env:
72+
REPO: ${{ github.repository }}
73+
run: |
74+
workflow_path=${GITHUB_WORKFLOW_REF#*/} # 去掉owner
75+
workflow_path=${workflow_path#*/} # 去掉repo名
76+
workflow_path=${workflow_path%@*} # 去掉@ref
77+
action_file="https://github.com/$REPO/blob/$GITHUB_SHA/$workflow_path"
78+
echo "action_file=$action_file" >> $GITHUB_OUTPUT
79+
80+
- name: Generate GitHub App token
81+
id: app-token
82+
uses: actions/create-github-app-token@v1
83+
with:
84+
app-id: ${{ vars.DAILY_BOT_APP_ID }}
85+
private-key: ${{ secrets.DAILY_BOT_APP_PRIVATE_KEY }}
86+
87+
- name: Comment on issue
88+
uses: actions/github-script@v7
89+
with:
90+
github-token: ${{ steps.app-token.outputs.token }}
91+
script: |
92+
const now = new Date().toLocaleString('zh-CN', {
93+
timeZone: 'Asia/Shanghai',
94+
hour12: false
95+
});
96+
97+
const actionFile = `${{ steps.resolve-workflow-path.outputs.action_file }}`
98+
99+
await github.rest.issues.createComment({
100+
owner: context.repo.owner,
101+
repo: context.repo.repo,
102+
issue_number: context.issue.number,
103+
body: `This issue was automatically added to the project.\n🕒 Time (Beijing, UTC+8): ${now}\n🤖 Triggered by [1problem1day Bot](https://github.com/apps/1problem1day) according to [action file](${actionFile})`
104+
});

.github/workflows/1problem1day-autoGenIssueEveryday.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: LeetCode Daily Issue
1+
name: Daily / Generate LeetCode Daily Issue
22

33
# 每天北京时间0点自动创建今天的每日一题issue
44

@@ -36,13 +36,18 @@ jobs:
3636
- name: Create issue
3737
env:
3838
GH_TOKEN: ${{ secrets.ONE_PROBLEM_ONE_DAY_PAT }}
39+
REPO: ${{ github.repository }}
3940
run: |
4041
IFS='|' read -r id slug title < daily.txt
4142
date=$(TZ=Asia/Shanghai date +%Y-%m-%d)
4243
44+
workflow_path=${GITHUB_WORKFLOW_REF#*/} # 去掉owner
45+
workflow_path=${workflow_path#*/} # 去掉repo名
46+
workflow_path=${workflow_path%@*} # 去掉@ref
47+
4348
gh issue create \
4449
--title "[newSolution]Who can add 1 more problem of LeetCode $id" \
45-
--body "By Github Actions | [$id.$title](https://leetcode.cn/problems/$slug/) | $date" \
50+
--body "By Github [Actions](https://github.com/$REPO/blob/$GITHUB_SHA/$workflow_path) | [$id.$title](https://leetcode.cn/problems/$slug/) | $date" \
4651
--label 题解 \
4752
--assignee LetMeFly666 \
48-
--repo "${{ github.repository }}"
53+
--repo "$REPO"

.github/workflows/1problem1day-closeAndSetDate.yml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Handle issue close
1+
name: Daily / Handle issue close
22
# 当有issue被关闭时,自动在project中填写完成日期
33

44
on:
@@ -18,6 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919
steps:
2020
- name: Set finish date & done
21+
id: set-state
2122
env:
2223
GH_TOKEN: ${{ secrets.ONE_PROBLEM_ONE_DAY_PAT }}
2324
run: |
@@ -45,6 +46,7 @@ jobs:
4546
| .id")
4647
if [[ -z "$item_id" ]]; then
4748
echo "Issue not in project, skip"
49+
echo "skip=true" >> $GITHUB_OUTPUT
4850
exit 0
4951
fi
5052
echo "Found item_id = $item_id"
@@ -66,4 +68,44 @@ jobs:
6668
-f item="$item_id" \
6769
-f field="$FINISH_DATE_FIELD_ID" \
6870
-f date="$date_cn"
71+
echo "date_cn=$date_cn" >> $GITHUB_OUTPUT
6972
echo "Set Finish Date successfully ✅"
73+
74+
- name: Resolve workflow path
75+
id: resolve-workflow-path
76+
if: steps.set-state.outputs.skip != 'true'
77+
env:
78+
REPO: ${{ github.repository }}
79+
run: |
80+
workflow_path=${GITHUB_WORKFLOW_REF#*/} # 去掉owner
81+
workflow_path=${workflow_path#*/} # 去掉repo名
82+
workflow_path=${workflow_path%@*} # 去掉@ref
83+
action_file="https://github.com/$REPO/blob/$GITHUB_SHA/$workflow_path"
84+
echo "action_file=$action_file" >> $GITHUB_OUTPUT
85+
86+
- name: Generate GitHub App token
87+
id: app-token
88+
uses: actions/create-github-app-token@v1
89+
with:
90+
app-id: ${{ vars.DAILY_BOT_APP_ID }}
91+
private-key: ${{ secrets.DAILY_BOT_APP_PRIVATE_KEY }}
92+
93+
- name: Comment on issue
94+
uses: actions/github-script@v7
95+
with:
96+
github-token: ${{ steps.app-token.outputs.token }}
97+
script: |
98+
const now = new Date().toLocaleString('zh-CN', {
99+
timeZone: 'Asia/Shanghai',
100+
hour12: false
101+
});
102+
103+
const actionFile = `${{ steps.resolve-workflow-path.outputs.action_file }}`;
104+
const setToDate = `${{ steps.set-state.outputs.date_cn }}`;
105+
106+
await github.rest.issues.createComment({
107+
owner: context.repo.owner,
108+
repo: context.repo.repo,
109+
issue_number: context.issue.number,
110+
body: `Set finish date = ${setToDate} in project.\n🕒 Time (Beijing, UTC+8): ${now}\n🤖 Triggered by [1problem1day Bot](https://github.com/apps/1problem1day) according to [action file](${actionFile})`
111+
});

.github/workflows/1problem1day-label.yml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Sync solving label to project status
1+
name: Daily / Sync solving label to project status
22
# 仅对issue增删的solving标签生效:
33
# 添加solving标签->设置Project状态为In Progress
44
# 移除solving标签-↓
@@ -23,6 +23,7 @@ jobs:
2323
runs-on: ubuntu-latest
2424
steps:
2525
- name: Update project status by solving label
26+
id: update-status
2627
env:
2728
GH_TOKEN: ${{ secrets.ONE_PROBLEM_ONE_DAY_PAT }}
2829
run: |
@@ -66,6 +67,7 @@ jobs:
6667
| .id")
6768
if [[ -z "$item_id" ]]; then
6869
echo "Issue not in project, skip"
70+
echo "skip=true" >> $GITHUB_OUTPUT
6971
exit 0
7072
fi
7173
echo "Found item_id = $item_id"
@@ -79,6 +81,7 @@ jobs:
7981
status="Todo"
8082
fi
8183
fi
84+
echo "status=$status" >> $GITHUB_OUTPUT
8285
echo "Target status name = $status"
8386
8487
echo "Resolve status option ID..."
@@ -149,3 +152,42 @@ jobs:
149152
-F option="$option_id"
150153
fi
151154
echo "Status updated successfully ✅"
155+
156+
- name: Resolve workflow path
157+
id: resolve-workflow-path
158+
if: steps.update-status.outputs.skip != 'true'
159+
env:
160+
REPO: ${{ github.repository }}
161+
run: |
162+
workflow_path=${GITHUB_WORKFLOW_REF#*/} # 去掉owner
163+
workflow_path=${workflow_path#*/} # 去掉repo名
164+
workflow_path=${workflow_path%@*} # 去掉@ref
165+
action_file="https://github.com/$REPO/blob/$GITHUB_SHA/$workflow_path"
166+
echo "action_file=$action_file" >> $GITHUB_OUTPUT
167+
168+
- name: Generate GitHub App token
169+
id: app-token
170+
uses: actions/create-github-app-token@v1
171+
with:
172+
app-id: ${{ vars.DAILY_BOT_APP_ID }}
173+
private-key: ${{ secrets.DAILY_BOT_APP_PRIVATE_KEY }}
174+
175+
- name: Comment on issue
176+
uses: actions/github-script@v7
177+
with:
178+
github-token: ${{ steps.app-token.outputs.token }}
179+
script: |
180+
const now = new Date().toLocaleString('zh-CN', {
181+
timeZone: 'Asia/Shanghai',
182+
hour12: false
183+
});
184+
185+
const actionFile = `${{ steps.resolve-workflow-path.outputs.action_file }}`;
186+
const status = `${{ steps.update-status.outputs.status }}`;
187+
188+
await github.rest.issues.createComment({
189+
owner: context.repo.owner,
190+
repo: context.repo.repo,
191+
issue_number: context.issue.number,
192+
body: `Set the project status to ${status} based on the \`solving\` label.\n🕒 Time (Beijing, UTC+8): ${now}\n🤖 Triggered by [1problem1day Bot](https://github.com/apps/1problem1day) according to [action file](${actionFile})`
193+
});

Codes/0955-delete-columns-to-make-sorted-ii.go

Lines changed: 0 additions & 5 deletions
This file was deleted.

Codes/0955-delete-columns-to-make-sorted-ii.java

Lines changed: 0 additions & 5 deletions
This file was deleted.

Codes/0955-delete-columns-to-make-sorted-ii.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

Codes/0955-delete-columns-to-make-sorted-ii.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* @Author: LetMeFly
3+
* @Date: 2025-12-22 22:28:49
4+
* @LastEditors: LetMeFly.xyz
5+
* @LastEditTime: 2025-12-22 22:43:18
6+
*/
7+
#if defined(_WIN32) || defined(__APPLE__)
8+
#include "_[1,2]toVector.h"
9+
#endif
10+
11+
class Solution {
12+
private:
13+
bool can(vector<string>& strs, int i, int j) {
14+
for (string& s : strs) {
15+
if (s[i] < s[j]) {
16+
return false;
17+
}
18+
}
19+
return true;
20+
}
21+
public:
22+
int minDeletionSize(vector<string>& strs) {
23+
int m = strs[0].size();
24+
vector<int> dp(m);
25+
for (int i = 0; i < m; i++) { // 一定要从0开始!!要不然dp[0]恒为0
26+
for (int j = 0; j < i; j++) {
27+
if (dp[j] > dp[i] && can(strs, i, j)) {
28+
dp[i] = dp[j];
29+
}
30+
}
31+
dp[i]++;
32+
}
33+
return m - *max_element(dp.begin(), dp.end());
34+
}
35+
};

0 commit comments

Comments
 (0)