Skip to content

Commit e63c057

Browse files
author
lucifer
committed
feat: 更新模板和精选题解
1 parent 48d8bd1 commit e63c057

21 files changed

+269
-20
lines changed

‎leetcode-cheat.zip

13.4 KB
Binary file not shown.

‎public/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 2,
33
"name": "leetcode cheatsheet",
44
"description": "刷题小助手,made by 力扣加加",
5-
"version": "0.2.1",
5+
"version": "0.2.2",
66
"browser_action": {
77
"default_popup": "index.html",
88
"default_title": "力扣加加"

‎src/App.css

+10
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,13 @@
2424
display: inline-block;
2525
width: 80px;
2626
}
27+
28+
.problem-icon {
29+
width: 20px;
30+
height: 20px;
31+
}
32+
33+
.header-icon {
34+
width: 30px;
35+
height: 30px;
36+
}

‎src/App.js

+56-10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { Button, Table, Empty, Collapse, Tabs } from "antd";
44
import "highlight.js/styles/github.css";
55

66
import db from "./db/db";
7+
import collectionLogo from "./imgs/collection.svg";
8+
import viewLogo from "./imgs/view.svg";
9+
710
import {
811
LEETCODE_CN_URL,
912
LEETCODE_URL,
@@ -19,7 +22,7 @@ import "antd/dist/antd.css";
1922
import "./App.css";
2023
// import { data as a } from "./db/binary-tree";
2124

22-
const { problems } = db;
25+
const { problems, selected } = db;
2326
const { TabPane } = Tabs;
2427
const { Panel } = Collapse;
2528
const dataSource = Object.values(problems);
@@ -80,14 +83,21 @@ function App() {
8083
const problemId = match && match[1];
8184
setProblemId(problemId);
8285
setHasSolution(!!problems[problemId]);
86+
setInSelected(!!selected[problemId]);
8387
setInLeetCode(inLeetCodeWebsite(currentUrl));
8488
});
8589

90+
// setTimeout(() => {
91+
// setProblemId("uncrossed-lines");
92+
// // setProblemId("two-sum");
93+
// setInSelected(!!selected[problemId]);
94+
// setHasSolution(!!problems[problemId]);
95+
// }, 1000);
96+
8697
const [problemId, setProblemId] = useState("");
87-
// const [problemId, setProblemId] = useState("two-sum");
8898

8999
const [hasSolution, setHasSolution] = useState(false);
90-
// const [hasSolution, setHasSolution] = useState(true);
100+
const [inSelected, setInSelected] = useState(false); // 是否被精选题解(其实就是合集)收录
91101
const [page, setPage] = useState("");
92102
const [inLeetCode, setInLeetCode] = useState(true);
93103

@@ -131,24 +141,60 @@ function App() {
131141
{hasSolution && page === "" ? (
132142
<Button type="link" onClick={() => setPage("detail")}>
133143
查看本题题解
144+
<img
145+
src={viewLogo}
146+
className="problem-icon"
147+
style={{ margin: "0 0 0 10px" }}
148+
/>
134149
</Button>
135150
) : (
136151
""
137152
)}
138153

139-
{!hasSolution && page !== "allSolutions" && (
140-
<Button type="link" onClick={() => setPage("allSolutions")}>
141-
本题暂未被力扣加加收录,点击查看所有已收录题目~
142-
</Button>
143-
)}
154+
{!hasSolution &&
155+
page !== "allSolutions" &&
156+
(inSelected ? (
157+
<Button
158+
type="link"
159+
target="_blank"
160+
href={selected[problemId].url}
161+
>
162+
该题已被收录到精选合集《{selected[problemId].title}》点击查看
163+
<img
164+
src={collectionLogo}
165+
className="problem-icon"
166+
style={{ margin: "0 0 0 10px" }}
167+
/>
168+
</Button>
169+
) : (
170+
<Button type="link" onClick={() => setPage("allSolutions")}>
171+
本题暂未被力扣加加收录,点击查看所有已收录题目~
172+
</Button>
173+
))}
144174

145175
<div style={page === "" ? {} : { display: "none" }}>
146176
<h2 style={{ display: "flex", justifyContent: "center" }}>
147-
代码模��(内测中)
177+
代码模板
148178
</h2>
149179
<Tabs>
150180
{tempaltes.map((tempalte) => (
151-
<TabPane tab={tempalte.title} key={tempalte.title}>
181+
<TabPane
182+
tab={
183+
<div>
184+
{tempalte.title}
185+
<img
186+
style={
187+
tempalte.logo
188+
? { margin: "0 0 0 10px" }
189+
: { display: "none" }
190+
}
191+
src={tempalte.logo}
192+
className="problem-icon"
193+
/>
194+
</div>
195+
}
196+
key={tempalte.title}
197+
>
152198
{tempalte.link && (
153199
<div>
154200
建议先学会之后再用模板。 如果你还不会的话,可以看看我的

‎src/Detail.jsx

-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ export default function Detail({ problemId }) {
107107
></TabPane>
108108

109109
<TabPane tab="我要反馈" key="feedback">
110-
<div>当前版本: V 0.2.1</div>
111110
<a
112111
href={ISSUES_URL}
113112
target="_blank"

‎src/codeTemplates/bfs.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
module.exports = {
1+
import bfsLogo from "../imgs/bfs.svg";
2+
3+
export default {
24
title: "BFS",
5+
logo: bfsLogo,
36
list: [
47
{
58
text: "带层信息",

‎src/codeTemplates/binarySearch.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
module.exports = {
1+
import halfLogo from "../imgs/half.svg";
2+
3+
export default {
24
title: "二分法",
5+
logo: halfLogo,
36
list: [
47
{
58
text: "查找一个数",

‎src/codeTemplates/segmentTree.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import segmentLogo from "../imgs/segment.svg";
2+
13
const pyCode = `
24
class SegmentTree:
35
def __init__(self, data:List[int]):
@@ -83,8 +85,9 @@ class SegmentTree:
8385
self.tree[tree_index] = self.tree[left] + self.tree[right]
8486
`;
8587

86-
module.exports = {
88+
export default {
8789
title: "线段树",
90+
logo: segmentLogo,
8891
list: [
8992
{
9093
text: "区间和线段树",

‎src/codeTemplates/sliding-window.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
module.exports = {
1+
import windowLogo from "../imgs/window.svg";
2+
export default {
23
title: "滑动窗口",
4+
logo: windowLogo,
35
list: [
46
{
57
text: "固定窗口(伪代码)",

‎src/codeTemplates/trie.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
module.exports = {
1+
import treeLogo from "../imgs/tree.svg";
2+
3+
export default {
24
title: "前缀树",
5+
logo: treeLogo,
36
list: [
47
{
58
text: "标准前缀树",

‎src/codeTemplates/uf.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
module.exports = {
1+
import ufLogo from "../imgs/uf.svg";
2+
3+
export default {
24
title: "并查集",
5+
logo: ufLogo,
36
list: [
47
{
58
text: "乞丐版",
@@ -46,7 +49,7 @@ class UF:
4649
],
4750
},
4851
{
49-
text: "带路径压缩(递归)",
52+
text: "带路径压缩(迭代)",
5053
problems: [
5154
{
5255
title: "547. 朋友圈",
@@ -101,7 +104,7 @@ class UF:
101104
},
102105

103106
{
104-
text: "带路径压缩(迭代)",
107+
text: "带路径压缩(递归)",
105108
problems: [
106109
{
107110
title: "547. 朋友圈",

‎src/db/db.js

+135
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,141 @@ import { db_collection } from "./root.db";
3636
// };
3737

3838
const company = {};
39+
const selected = {
40+
"remove-duplicate-letters": {
41+
id: 316,
42+
name: "remove-duplicate-letters",
43+
title: "一招吃遍力扣四道题,妈妈再也不用担心我被套路啦~",
44+
url:
45+
"https://github.com/azl397985856/leetcode/blob/master/selected/a-deleted.md",
46+
},
47+
"create-maximum-number": {
48+
id: 321,
49+
name: "create-maximum-number",
50+
title: "一招吃遍力扣四道题,妈妈再也不用担心我被套路啦~",
51+
url:
52+
"https://github.com/azl397985856/leetcode/blob/master/selected/a-deleted.md",
53+
},
54+
"remove-k-digits": {
55+
id: 402,
56+
name: "remove-k-digits",
57+
title: "一招吃遍力扣四道题,妈妈再也不用担心我被套路啦~",
58+
url:
59+
"https://github.com/azl397985856/leetcode/blob/master/selected/a-deleted.md",
60+
},
61+
"smallest-subsequence-of-distinct-characters": {
62+
id: 1081,
63+
name: "smallest-subsequence-of-distinct-characters",
64+
title: "一招吃遍力扣四道题,妈妈再也不用担心我被套路啦~",
65+
url:
66+
"https://github.com/azl397985856/leetcode/blob/master/selected/a-deleted.md",
67+
},
68+
"unique-substrings-in-wraparound-string": {
69+
id: 467,
70+
name: "unique-substrings-in-wraparound-string",
71+
title: "【西法的刷题秘籍】一次搞定前缀和",
72+
url:
73+
"https://github.com/azl397985856/leetcode/blob/master/selected/atMostK.md",
74+
},
75+
"number-of-subarrays-with-bounded-maximum": {
76+
id: 795,
77+
name: "number-of-subarrays-with-bounded-maximum",
78+
title: "【西法的刷题秘籍】一次搞定前缀和",
79+
url:
80+
"https://github.com/azl397985856/leetcode/blob/master/selected/atMostK.md",
81+
},
82+
"fruit-into-baskets": {
83+
id: 904,
84+
name: "fruit-into-baskets",
85+
title: "【西法的刷题秘籍】一次搞定前缀和",
86+
url:
87+
"https://github.com/azl397985856/leetcode/blob/master/selected/atMostK.md",
88+
},
89+
"subarrays-with-k-different-integers": {
90+
id: 992,
91+
name: "subarrays-with-k-different-integers",
92+
title: "【西法的刷题秘籍】一次搞定前缀和",
93+
url:
94+
"https://github.com/azl397985856/leetcode/blob/master/selected/atMostK.md",
95+
},
96+
"corporate-flight-bookings": {
97+
id: 1109,
98+
name: "corporate-flight-bookings",
99+
title: "【西法的刷题秘籍】一次搞定前缀和",
100+
url:
101+
"https://github.com/azl397985856/leetcode/blob/master/selected/atMostK.md",
102+
},
103+
"serialize-and-deserialize-bst": {
104+
id: 449,
105+
name: "serialize-and-deserialize-bst",
106+
title: "一文带你看懂二叉树的序列化",
107+
url:
108+
"https://github.com/azl397985856/leetcode/blob/master/selected/serialize.md",
109+
},
110+
"serialize-and-deserialize-binary-tree": {
111+
id: 297,
112+
name: "serialize-and-deserialize-binary-tree",
113+
title: "一文带你看懂二叉树的序列化",
114+
url:
115+
"https://github.com/azl397985856/leetcode/blob/master/selected/serialize.md",
116+
},
39117

118+
"longest-increasing-subsequence": {
119+
id: 300,
120+
name: "longest-increasing-subsequence",
121+
title: "穿上衣服我就不认识你了?来聊聊最长上升子序列",
122+
url:
123+
"https://github.com/azl397985856/leetcode/blob/master/selected/serialize.md",
124+
},
125+
"non-overlapping-intervals": {
126+
id: 435,
127+
name: "non-overlapping-intervals",
128+
title: "穿上衣服我就不认识你了?来聊聊最长上升子序列",
129+
url:
130+
"https://github.com/azl397985856/leetcode/blob/master/selected/serialize.md",
131+
},
132+
"maximum-length-of-pair-chain": {
133+
id: 646,
134+
name: "maximum-length-of-pair-chain",
135+
title: "穿上衣服我就不认识你了?来聊聊最长上升子序列",
136+
url:
137+
"https://github.com/azl397985856/leetcode/blob/master/selected/serialize.md",
138+
},
139+
"minimum-number-of-arrows-to-burst-balloons": {
140+
id: 452,
141+
name: "minimum-number-of-arrows-to-burst-balloons",
142+
title: "穿上衣服我就不认识你了?来聊聊最长上升子序列",
143+
url:
144+
"https://github.com/azl397985856/leetcode/blob/master/selected/serialize.md",
145+
},
146+
147+
"maximum-length-of-repeated-subarray": {
148+
id: 718,
149+
name: "maximum-length-of-repeated-subarray",
150+
title: "你的衣服我扒了 - 《最长公共子序列》",
151+
url: "https://github.com/azl397985856/leetcode/blob/master/selected/LCS.md",
152+
},
153+
"longest-common-subsequence": {
154+
id: 1143,
155+
name: "longest-common-subsequence",
156+
title: "你的衣服我扒了 - 《最长公共子序列》",
157+
url: "https://github.com/azl397985856/leetcode/blob/master/selected/LCS.md",
158+
},
159+
"uncrossed-lines": {
160+
id: 1035,
161+
name: "uncrossed-lines",
162+
title: "你的衣服我扒了 - 《最长公共子序列》",
163+
url: "https://github.com/azl397985856/leetcode/blob/master/selected/LCS.md",
164+
},
165+
"maximum-subarray": {
166+
id: 53,
167+
name: "maximum-subarray",
168+
title: "一文看懂《最大子序列和问题》",
169+
url: "https://github.com/azl397985856/leetcode/blob/master/selected/LSS.md",
170+
},
171+
};
172+
173+
const in91 = {};
40174
Object.values(db_collection).forEach((problem) => {
41175
problem.companies.forEach((c) => {
42176
if (company[c.name] === void 0) company[c.name] = [];
@@ -48,4 +182,5 @@ export default {
48182
problems: db_collection,
49183
// tags,
50184
company,
185+
selected,
51186
};

0 commit comments

Comments
 (0)