Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
于光远
skill_tree_algorithm
提交
a73ff9b0
S
skill_tree_algorithm
项目概览
于光远
/
skill_tree_algorithm
与 Fork 源项目一致
Fork自
CSDN 技术社区 / skill_tree_algorithm
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
skill_tree_algorithm
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a73ff9b0
编写于
11月 18, 2021
作者:
F
feilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
edit exe
上级
ef4af1a4
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
185 addition
and
199 deletion
+185
-199
data/2.算法中阶/4.leetcode-栈与队列/9.150-逆波兰表达式求值/solution.md
data/2.算法中阶/4.leetcode-栈与队列/9.150-逆波兰表达式求值/solution.md
+1
-6
data/2.算法中阶/5.leetcode-排序算法/9.315-计算右侧小于当前元素的个数/solution.md
data/2.算法中阶/5.leetcode-排序算法/9.315-计算右侧小于当前元素的个数/solution.md
+0
-4
data/3.算法高阶/1.leetcode-树/10.103-二叉树的锯齿形层序遍历/solution.md
data/3.算法高阶/1.leetcode-树/10.103-二叉树的锯齿形层序遍历/solution.md
+4
-4
data/3.算法高阶/1.leetcode-树/9.102-二叉树的层序遍历/solution.md
data/3.算法高阶/1.leetcode-树/9.102-二叉树的层序遍历/solution.md
+4
-12
data/3.算法高阶/2.leetcode-哈希表/3.36-有效的数独/solution.md
data/3.算法高阶/2.leetcode-哈希表/3.36-有效的数独/solution.md
+14
-4
data/3.算法高阶/2.leetcode-哈希表/8.127-单词接龙/solution.md
data/3.算法高阶/2.leetcode-哈希表/8.127-单词接龙/solution.md
+0
-1
data/3.算法高阶/3.leetcode-图与搜索/2.133-克隆图/solution.md
data/3.算法高阶/3.leetcode-图与搜索/2.133-克隆图/solution.md
+4
-4
data/3.算法高阶/4.leetcode-数学/2.12-整数转罗马数字/solution.md
data/3.算法高阶/4.leetcode-数学/2.12-整数转罗马数字/solution.md
+38
-37
data/3.算法高阶/4.leetcode-数学/9.13-罗马数字转整数/solution.md
data/3.算法高阶/4.leetcode-数学/9.13-罗马数字转整数/solution.md
+37
-37
data/3.算法高阶/5.leetcode-设计/1.355-设计推特/solution.md
data/3.算法高阶/5.leetcode-设计/1.355-设计推特/solution.md
+7
-9
data/3.算法高阶/5.leetcode-设计/2.380-O(1) 时间插入、删除和获取随机元素/solution.md
....算法高阶/5.leetcode-设计/2.380-O(1) 时间插入、删除和获取随机元素/solution.md
+6
-11
data/3.算法高阶/7.leetcode-回溯算法/9.37-解数独/solution.md
data/3.算法高阶/7.leetcode-回溯算法/9.37-解数独/solution.md
+24
-22
data/3.算法高阶/8.leetcode-贪心/3.68-文本左右对齐/solution.md
data/3.算法高阶/8.leetcode-贪心/3.68-文本左右对齐/solution.md
+46
-48
未找到文件。
data/2.算法中阶/4.leetcode-栈与队列/9.150-逆波兰表达式求值/solution.md
浏览文件 @
a73ff9b0
...
@@ -47,18 +47,13 @@
...
@@ -47,18 +47,13 @@
<strong>
解释:
</strong>
<strong>
解释:
</strong>
该算式转化为常见的中缀算术表达式为:
该算式转化为常见的中缀算术表达式为:
((10
* (6 / ((9 + 3) *
-11))) + 17) + 5
((10
* (6 / ((9 + 3) *
-11))) + 17) + 5
= ((10
* (6 / (12 *
-11))) + 17) + 5
= ((10
* (6 / (12 *
-11))) + 17) + 5
= ((10
*
(6 / -132)) + 17) + 5
= ((10
*
(6 / -132)) + 17) + 5
= ((10
*
0) + 17) + 5
= ((10
*
0) + 17) + 5
= (0 + 17) + 5
= (0 + 17) + 5
= 17 + 5
= 17 + 5
= 22
</pre>
= 22
</pre>
<p>
</p>
<p>
</p>
...
...
data/2.算法中阶/5.leetcode-排序算法/9.315-计算右侧小于当前元素的个数/solution.md
浏览文件 @
a73ff9b0
...
@@ -12,13 +12,9 @@
...
@@ -12,13 +12,9 @@
<strong>输出:</strong><code>[2,1,1,0]
<strong>输出:</strong><code>[2,1,1,0]
<strong>解释:</strong></code>
<strong>解释:</strong></code>
5 的右侧有 <strong>2 </strong>个更小的元素 (2 和 1)
5 的右侧有 <strong>2 </strong>个更小的元素 (2 和 1)
2 的右侧仅有 <strong>1 </strong>个更小的元素 (1)
2 的右侧仅有 <strong>1 </strong>个更小的元素 (1)
6 的右侧有 <strong>1 </strong>个更小的元素 (1)
6 的右侧有 <strong>1 </strong>个更小的元素 (1)
1 的右侧有 <strong>0 </strong>个更小的元素
1 的右侧有 <strong>0 </strong>个更小的元素
</pre>
</pre>
...
...
data/3.算法高阶/1.leetcode-树/10.103-二叉树的锯齿形层序遍历/solution.md
浏览文件 @
a73ff9b0
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
给定二叉树
<code>
[3,9,20,null,null,15,7]
</code>
,
</p>
给定二叉树
<code>
[3,9,20,null,null,15,7]
</code>
,
</p>
<pre>
```
3
3
/ \
/ \
...
@@ -16,11 +16,11 @@
...
@@ -16,11 +16,11 @@
/ \
/ \
15 7
15 7
</pre>
```
<p>
返回锯齿形层序遍历如下:
</p>
<p>
返回锯齿形层序遍历如下:
</p>
<pre>
```
[
[
[3],
[3],
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
[15,7]
[15,7]
]
]
</pre>
```
<p>
以下
<span
style=
"color:red"
>
错误
</span>
的选项是?
</p>
<p>
以下
<span
style=
"color:red"
>
错误
</span>
的选项是?
</p>
...
...
data/3.算法高阶/1.leetcode-树/9.102-二叉树的层序遍历/solution.md
浏览文件 @
a73ff9b0
...
@@ -8,31 +8,23 @@
...
@@ -8,31 +8,23 @@
二叉树:
<code>
[3,9,20,null,null,15,7]
</code>
,
</p>
二叉树:
<code>
[3,9,20,null,null,15,7]
</code>
,
</p>
<pre>
```
3
3
/ \
/ \
9 20
9 20
/ \
/ \
15 7
15 7
</pre>
```
<p>
返回其层序遍历结果:
</p>
<p>
返回其层序遍历结果:
</p>
<pre>
```
[
[
[3],
[3],
[9,20],
[9,20],
[15,7]
[15,7]
]
]
</pre>
```
<p>
以下
<span
style=
"color:red"
>
错误
</span>
的选项是?
</p>
<p>
以下
<span
style=
"color:red"
>
错误
</span>
的选项是?
</p>
...
...
data/3.算法高阶/2.leetcode-哈希表/3.36-有效的数独/solution.md
浏览文件 @
a73ff9b0
...
@@ -16,7 +16,10 @@
...
@@ -16,7 +16,10 @@
<p><strong>
示例 1:
</strong></p>
<img
<p><strong>
示例 1:
</strong></p>
<img
src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0036.Valid%20Sudoku/images/250px-sudoku-by-l2g-20050714svg.png"
src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0036.Valid%20Sudoku/images/250px-sudoku-by-l2g-20050714svg.png"
style="height:250px; width:250px" />
style="height:250px; width:250px" />
<pre><strong>
输入:
</strong>
board =
<strong>
输入:
</strong>
```
board =
[["5","3",".",".","7",".",".",".","."]
[["5","3",".",".","7",".",".",".","."]
,["6",".",".","1","9","5",".",".","."]
,["6",".",".","1","9","5",".",".","."]
,[".","9","8",".",".",".",".","6","."]
,[".","9","8",".",".",".",".","6","."]
...
@@ -26,10 +29,15 @@
...
@@ -26,10 +29,15 @@
,[".","6",".",".",".",".","2","8","."]
,[".","6",".",".",".",".","2","8","."]
,[".",".",".","4","1","9",".",".","5"]
,[".",".",".","4","1","9",".",".","5"]
,[".",".",".",".","8",".",".","7","9"]]
,[".",".",".",".","8",".",".","7","9"]]
```
<strong><br
/>
输出:
</strong>
true
<strong><br
/>
输出:
</strong>
true
</pre>
<p><strong>
示例 2:
</strong></p>
<p><strong>
示例 2:
</strong></p>
<pre><strong>
输入:
</strong>
board =
<strong>
输入:
</strong>
```
board =
[["8","3",".",".","7",".",".",".","."]
[["8","3",".",".","7",".",".",".","."]
,["6",".",".","1","9","5",".",".","."]
,["6",".",".","1","9","5",".",".","."]
,[".","9","8",".",".",".",".","6","."]
,[".","9","8",".",".",".",".","6","."]
...
@@ -39,8 +47,10 @@
...
@@ -39,8 +47,10 @@
,[".","6",".",".",".",".","2","8","."]
,[".","6",".",".",".",".","2","8","."]
,[".",".",".","4","1","9",".",".","5"]
,[".",".",".","4","1","9",".",".","5"]
,[".",".",".",".","8",".",".","7","9"]]
,[".",".",".",".","8",".",".","7","9"]]
```
<strong><br
/>
输出:
</strong>
false
<strong><br
/>
输出:
</strong>
false
<strong><br
/>
解释:
</strong>
除了第一行的第一个数字从
<strong>
5
</strong>
改为
<strong>
8
</strong>
以外,空格内其他数字均与 示例1 相同。 但由于位于左上角的 3x3 宫内有两个 8 存在, 因此这个数独是无效的。
</pre>
<strong><br
/>
解释:
</strong>
除了第一行的第一个数字从
<strong>
5
</strong>
改为
<strong>
8
</strong>
以外,空格内其他数字均与 示例1 相同。 但由于位于左上角的 3x3 宫内有两个 8 存在, 因此这个数独是无效的。
<p>
</p>
<p>
</p>
<p><strong>
提示:
</strong></p>
<p><strong>
提示:
</strong></p>
<ul>
<ul>
...
...
data/3.算法高阶/2.leetcode-哈希表/8.127-单词接龙/solution.md
浏览文件 @
a73ff9b0
...
@@ -25,7 +25,6 @@
...
@@ -25,7 +25,6 @@
<p><strong>
示例 2:
</strong></p>
<p><strong>
示例 2:
</strong></p>
<pre>
<strong>
输入:
</strong>
beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log"]
<strong>
输入:
</strong>
beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log"]
<strong>
输出:
</strong>
0
<strong>
输出:
</strong>
0
...
...
data/3.算法高阶/3.leetcode-图与搜索/2.133-克隆图/solution.md
浏览文件 @
a73ff9b0
...
@@ -4,12 +4,12 @@
...
@@ -4,12 +4,12 @@
<p>
图中的每个节点都包含它的值
<code>
val
</code>
(
<code>
int
</code>
) 和其邻居的列表(
<code>
list[Node]
</code>
)。
</p>
<p>
图中的每个节点都包含它的值
<code>
val
</code>
(
<code>
int
</code>
) 和其邻居的列表(
<code>
list[Node]
</code>
)。
</p>
<pre>
class Node {
```
java
class
Node
{
public
int
val
;
public
int
val
;
public
List
&
lt
;
Node
&
gt
;
neighbors
;
public
List
&
lt
;
Node
&
gt
;
neighbors
;
}
</pre>
}
```
<p>
</p>
<p>
</p>
...
...
data/3.算法高阶/4.leetcode-数学/2.12-整数转罗马数字/solution.md
浏览文件 @
a73ff9b0
# 整数转罗马数字
# 整数转罗马数字
<div
class=
"notranslate"
>
<p>
罗马数字包含以下七种字符:
<code>
I
</code>
,
<code>
V
</code>
,
<code>
X
</code>
,
<code>
L
</code>
,
<code>
C
</code>
,
<code>
D
</code>
和
<code>
M
</code>
。
<p>
罗马数字包含以下七种字符:
<code>
I
</code>
,
<code>
V
</code>
,
<code>
X
</code>
,
<code>
L
</code>
,
<code>
C
</code>
,
<code>
D
</code>
和
<code>
M
</code>
。
</p>
</p>
<pre><strong>字符</strong> <strong>数值</strong>
```
字符 数值
I 1
I 1
V 5
V 5
X 10
X 10
L 50
L 50
C 100
C 100
D 500
D 500
M 1000
</pre>
M 1000
```
<p>例如, 罗马数字 2 写做 <code>II</code> ,即为两个并列的 1。12
<p>
例如, 罗马数字 2 写做
<code>
II
</code>
,即为两个并列的 1。12
写做 <code>XII</code> ,即为 <code>X</code> + <code>II</code> 。 27
写做
<code>
XII
</code>
,即为
<code>
X
</code>
+
<code>
II
</code>
。 27
写做 <code>XXVII</code>,
写做
<code>
XXVII
</code>
,
即为 <code>XX</code> + <code>V</code> + <code>II</code> 。</p>
即为
<code>
XX
</code>
+
<code>
V
</code>
+
<code>
II
</code>
。
</p>
<p>通常情况下,罗马数字中小的数字在大的数字的右边。但也存在特例,例如 4 不写做 <code>IIII</code>,而是 <code>IV</code>。数字 1 在数字 5 的左边,所表示的数等于大数 5
<p>
通常情况下,罗马数字中小的数字在大的数字的右边。但也存在特例,例如 4 不写做
<code>
IIII
</code>
,而是
<code>
IV
</code>
。数字 1 在数字 5 的左边,所表示的数等于大数 5
减小数 1 得到的数值 4 。同样地,数字 9 表示为 <code>IX</code>。这个特殊的规则只适用于以下六种情况:</p>
减小数 1 得到的数值 4 。同样地,数字 9 表示为
<code>
IX
</code>
。这个特殊的规则只适用于以下六种情况:
</p>
<ul>
<ul>
<li><code>I</code> 可以放在 <code>V</code> (5) 和 <code>X</code> (10) 的左边,来表示 4 和 9。</li>
<li><code>
I
</code>
可以放在
<code>
V
</code>
(5) 和
<code>
X
</code>
(10) 的左边,来表示 4 和 9。
</li>
<li><code>X</code> 可以放在 <code>L</code> (50) 和 <code>C</code> (100) 的左边,来表示 40
<li><code>
X
</code>
可以放在
<code>
L
</code>
(50) 和
<code>
C
</code>
(100) 的左边,来表示 40
和 90。 </li>
和
90。
</li>
<li><code>C</code> 可以放在 <code>D</code> (500) 和 <code>M</code> (1000) 的左边,来表示 400
<li><code>
C
</code>
可以放在
<code>
D
</code>
(500) 和
<code>
M
</code>
(1000) 的左边,来表示
400
和 900。</li>
和
900。
</li>
</ul>
</ul>
<p>给你一个整数,将其转为罗马数字。</p>
<p>
给你一个整数,将其转为罗马数字。
</p>
<p> </p>
<p>
</p>
<p><strong>示例 1:</strong></p>
<p><strong>
示例
1:
</strong></p>
<pre><strong>输入:</strong> num = 3
<pre><strong>
输入:
</strong>
num = 3
<strong><br
/>
输出:
</strong>
"III"
</pre>
<strong><br
/>
输出:
</strong>
"III"
</pre>
<p><strong>示例 2:</strong></p>
<p><strong>
示例
2:
</strong></p>
<pre><strong>输入:</strong> num = 4
<pre><strong>
输入:
</strong>
num = 4
<strong><br
/>
输出:
</strong>
"IV"
</pre>
<strong><br
/>
输出:
</strong>
"IV"
</pre>
<p><strong>示例 3:</strong></p>
<p><strong>
示例
3:
</strong></p>
<pre><strong>输入:</strong> num = 9
<pre><strong>
输入:
</strong>
num = 9
<strong><br
/>
输出:
</strong>
"IX"
</pre>
<strong><br
/>
输出:
</strong>
"IX"
</pre>
<p><strong>示例 4:</strong></p>
<p><strong>
示例
4:
</strong></p>
<pre><strong>输入:</strong> num = 58
<pre><strong>
输入:
</strong>
num = 58
<strong><br
/>
输出:
</strong>
"LVIII"
<strong><br
/>
输出:
</strong>
"LVIII"
<strong><br
/>
解释:
</strong>
L = 50, V = 5, III = 3.
<strong><br
/>
解释:
</strong>
L = 50, V = 5, III = 3.
</pre>
</pre>
<p><strong>示例 5:</strong></p>
<p><strong>
示例
5:
</strong></p>
<pre><strong>输入:</strong> num = 1994
<pre><strong>
输入:
</strong>
num = 1994
<strong><br
/>
输出:
</strong>
"MCMXCIV"
<strong><br
/>
输出:
</strong>
"MCMXCIV"
<strong><br
/>
解释:
</strong>
M = 1000, CM = 900, XC = 90, IV = 4.
</pre>
<strong><br
/>
解释:
</strong>
M = 1000, CM = 900, XC = 90, IV = 4.
</pre>
<p> </p>
<p>
</p>
<p><strong>
提示:
</strong></p>
<p><strong>提示:</strong></p>
<ul>
<li><code>
1
<
= num
<
= 3999
</code></li>
</ul>
<ul>
<li><code>1 <= num <= 3999</code></li>
</ul>
</div>
<p>
以下
<span
style=
"color:red"
>
错误
</span>
的选项是?
</p>
<p>
以下
<span
style=
"color:red"
>
错误
</span>
的选项是?
</p>
## aop
## aop
...
...
data/3.算法高阶/4.leetcode-数学/9.13-罗马数字转整数/solution.md
浏览文件 @
a73ff9b0
# 罗马数字转整数
# 罗马数字转整数
<div
class=
"notranslate"
>
<p>
罗马数字包含以下七种字符:
<code>
I
</code>
,
<code>
V
</code>
,
<code>
X
</code>
,
<code>
L
</code>
,
<code>
C
</code>
,
<code>
D
</code>
和
<code>
M
</code>
。
<p>
罗马数字包含以下七种字符:
<code>
I
</code>
,
<code>
V
</code>
,
<code>
X
</code>
,
<code>
L
</code>
,
<code>
C
</code>
,
<code>
D
</code>
和
<code>
M
</code>
。
</p>
</p>
<pre><strong>字符</strong> <strong>数值</strong>
```
字符 数值
I 1
I 1
V 5
V 5
X 10
X 10
L 50
L 50
C 100
C 100
D 500
D 500
M 1000
</pre>
M 1000
```
<p>例如, 罗马数字 2 写做 <code>II</code> ,即为两个并列的 1。12
<p>
例如, 罗马数字 2 写做
<code>
II
</code>
,即为两个并列的 1。12
写做 <code>XII</code> ,即为 <code>X</code> + <code>II</code> 。 27
写做
<code>
XII
</code>
,即为
<code>
X
</code>
+
<code>
II
</code>
。 27
写做 <code>XXVII</code>,
写做
<code>
XXVII
</code>
,
即为 <code>XX</code> + <code>V</code> + <code>II</code> 。</p>
即为
<code>
XX
</code>
+
<code>
V
</code>
+
<code>
II
</code>
。
</p>
<p>通常情况下,罗马数字中小的数字在大的数字的右边。但也存在特例,例如 4 不写做 <code>IIII</code>,而是 <code>IV</code>。数字 1 在数字 5 的左边,所表示的数等于大数 5
<p>
通常情况下,罗马数字中小的数字在大的数字的右边。但也存在特例,例如 4 不写做
<code>
IIII
</code>
,而是
<code>
IV
</code>
。数字 1 在数字 5 的左边,所表示的数等于大数 5
减小数 1 得到的数值 4 。同样地,数字 9 表示为 <code>IX</code>。这个特殊的规则只适用于以下六种情况:</p>
减小数 1 得到的数值 4 。同样地,数字 9 表示为
<code>
IX
</code>
。这个特殊的规则只适用于以下六种情况:
</p>
<ul>
<ul>
<li><code>I</code> 可以放在 <code>V</code> (5) 和 <code>X</code> (10) 的左边,来表示 4 和 9。</li>
<li><code>
I
</code>
可以放在
<code>
V
</code>
(5) 和
<code>
X
</code>
(10) 的左边,来表示 4 和 9。
</li>
<li><code>X</code> 可以放在 <code>L</code> (50) 和 <code>C</code> (100) 的左边,来表示 40
<li><code>
X
</code>
可以放在
<code>
L
</code>
(50) 和
<code>
C
</code>
(100) 的左边,来表示 40
和 90。 </li>
和
90。
</li>
<li><code>C</code> 可以放在 <code>D</code> (500) 和 <code>M</code> (1000) 的左边,来表示 400
<li><code>
C
</code>
可以放在
<code>
D
</code>
(500) 和
<code>
M
</code>
(1000) 的左边,来表示
400
和 900。</li>
和
900。
</li>
</ul>
</ul>
<p>给你一个整数,将其转为罗马数字。</p>
<p>
给你一个整数,将其转为罗马数字。
</p>
<p> </p>
<p>
</p>
<p><strong>示例 1:</strong></p>
<p><strong>
示例
1:
</strong></p>
<pre><strong>输入:</strong> num = 3
<pre><strong>
输入:
</strong>
num = 3
<strong><br
/>
输出:
</strong>
"III"
</pre>
<strong><br
/>
输出:
</strong>
"III"
</pre>
<p><strong>示例 2:</strong></p>
<p><strong>
示例
2:
</strong></p>
<pre><strong>输入:</strong> num = 4
<pre><strong>
输入:
</strong>
num = 4
<strong><br
/>
输出:
</strong>
"IV"
</pre>
<strong><br
/>
输出:
</strong>
"IV"
</pre>
<p><strong>示例 3:</strong></p>
<p><strong>
示例
3:
</strong></p>
<pre><strong>输入:</strong> num = 9
<pre><strong>
输入:
</strong>
num = 9
<strong><br
/>
输出:
</strong>
"IX"
</pre>
<strong><br
/>
输出:
</strong>
"IX"
</pre>
<p><strong>示例 4:</strong></p>
<p><strong>
示例
4:
</strong></p>
<pre><strong>输入:</strong> num = 58
<pre><strong>
输入:
</strong>
num = 58
<strong><br
/>
输出:
</strong>
"LVIII"
<strong><br
/>
输出:
</strong>
"LVIII"
<strong><br
/>
解释:
</strong>
L = 50, V = 5, III = 3.
<strong><br
/>
解释:
</strong>
L = 50, V = 5, III = 3.
</pre>
</pre>
<p><strong>示例 5:</strong></p>
<p><strong>
示例
5:
</strong></p>
<pre><strong>输入:</strong> num = 1994
<pre><strong>
输入:
</strong>
num = 1994
<strong><br
/>
输出:
</strong>
"MCMXCIV"
<strong><br
/>
输出:
</strong>
"MCMXCIV"
<strong><br
/>
解释:
</strong>
M = 1000, CM = 900, XC = 90, IV = 4.
</pre>
<strong><br
/>
解释:
</strong>
M = 1000, CM = 900, XC = 90, IV = 4.
</pre>
<p> </p>
<p>
</p>
<p><strong>提示:</strong></p>
<p><strong>
提示:
</strong></p>
<ul>
<ul>
<li><code>1 <= num <= 3999</code></li>
<li><code>
1
<
= num
<
= 3999
</code></li>
</ul>
</ul>
</div>
<p>
以下
<span
style=
"color:red"
>
错误
</span>
的选项是?
</p>
<p>
以下
<span
style=
"color:red"
>
错误
</span>
的选项是?
</p>
## aop
## aop
...
...
data/3.算法高阶/5.leetcode-设计/1.355-设计推特/solution.md
浏览文件 @
a73ff9b0
...
@@ -16,34 +16,32 @@
...
@@ -16,34 +16,32 @@
<p><strong>
示例:
</strong></p>
<p><strong>
示例:
</strong></p>
<pre>
<strong>
输入
</strong>
<strong>
输入
</strong>
```
json
[
"Twitter"
,
"postTweet"
,
"getNewsFeed"
,
"follow"
,
"postTweet"
,
"getNewsFeed"
,
"unfollow"
,
"getNewsFeed"
]
[
"Twitter"
,
"postTweet"
,
"getNewsFeed"
,
"follow"
,
"postTweet"
,
"getNewsFeed"
,
"unfollow"
,
"getNewsFeed"
]
[[],
[
1
,
5
],
[
1
],
[
1
,
2
],
[
2
,
6
],
[
1
],
[
1
,
2
],
[
1
]]
[[],
[
1
,
5
],
[
1
],
[
1
,
2
],
[
2
,
6
],
[
1
],
[
1
,
2
],
[
1
]]
```
<strong>
输出
</strong>
<strong>
输出
</strong>
```
json
[
null
,
null
,
[
5
],
null
,
null
,
[
6
,
5
],
null
,
[
5
]]
[
null
,
null
,
[
5
],
null
,
null
,
[
6
,
5
],
null
,
[
5
]]
```
<strong>
解释
</strong>
<strong>
解释
</strong>
```
java
Twitter
twitter
=
new
Twitter
();
Twitter
twitter
=
new
Twitter
();
twitter
.
postTweet
(
1
,
5
);
// 用户 1 发送了一条新推文 (用户 id = 1, 推文 id = 5)
twitter
.
postTweet
(
1
,
5
);
// 用户 1 发送了一条新推文 (用户 id = 1, 推文 id = 5)
twitter
.
getNewsFeed
(
1
);
// 用户 1 的获取推文应当返回一个列表,其中包含一个 id 为 5 的推文
twitter
.
getNewsFeed
(
1
);
// 用户 1 的获取推文应当返回一个列表,其中包含一个 id 为 5 的推文
twitter
.
follow
(
1
,
2
);
// 用户 1 关注了用户 2
twitter
.
follow
(
1
,
2
);
// 用户 1 关注了用户 2
twitter
.
postTweet
(
2
,
6
);
// 用户 2 发送了一个新推文 (推文 id = 6)
twitter
.
postTweet
(
2
,
6
);
// 用户 2 发送了一个新推文 (推文 id = 6)
twitter
.
getNewsFeed
(
1
);
// 用户 1 的获取推文应当返回一个列表,其中包含两个推文,id 分别为 -> [6, 5] 。推文 id 6 应当在推文 id 5 之前,因为它是在 5 之后发送的
twitter
.
getNewsFeed
(
1
);
// 用户 1 的获取推文应当返回一个列表,其中包含两个推文,id 分别为 -> [6, 5] 。推文 id 6 应当在推文 id 5 之前,因为它是在 5 之后发送的
twitter
.
unfollow
(
1
,
2
);
// 用户 1 取消关注了用户 2
twitter
.
unfollow
(
1
,
2
);
// 用户 1 取消关注了用户 2
twitter
.
getNewsFeed
(
1
);
// 用户 1 获取推文应当返回一个列表,其中包含一个 id 为 5 的推文。因为用户 1 已经不再关注用户 2
twitter.getNewsFeed(1); // 用户 1 获取推文应当返回一个列表,其中包含一个 id 为 5 的推文。因为用户 1 已经不再关注用户 2
</pre>
```
<p>
</p>
<p>
</p>
...
...
data/3.算法高阶/5.leetcode-设计/2.380-O(1) 时间插入、删除和获取随机元素/solution.md
浏览文件 @
a73ff9b0
...
@@ -17,36 +17,31 @@
...
@@ -17,36 +17,31 @@
<p><strong>
示例:
</strong></p>
<p><strong>
示例:
</strong></p>
<pre>
<strong>
输入
</strong>
<strong>
输入
</strong>
```
json
[
"RandomizedSet"
,
"insert"
,
"remove"
,
"insert"
,
"getRandom"
,
"remove"
,
"insert"
,
"getRandom"
]
[
"RandomizedSet"
,
"insert"
,
"remove"
,
"insert"
,
"getRandom"
,
"remove"
,
"insert"
,
"getRandom"
]
[[],
[
1
],
[
2
],
[
2
],
[],
[
1
],
[
2
],
[]]
[[],
[
1
],
[
2
],
[
2
],
[],
[
1
],
[
2
],
[]]
```
<strong>
输出
</strong>
<strong>
输出
</strong>
```
json
[
null
,
true
,
false
,
true
,
2
,
true
,
false
,
2
]
[
null
,
true
,
false
,
true
,
2
,
true
,
false
,
2
]
```
<strong>
解释
</strong>
<strong>
解释
</strong>
```
java
RandomizedSet
randomizedSet
=
new
RandomizedSet
();
RandomizedSet
randomizedSet
=
new
RandomizedSet
();
randomizedSet
.
insert
(
1
);
// 向集合中插入 1 。返回 true 表示 1 被成功地插入。
randomizedSet
.
insert
(
1
);
// 向集合中插入 1 。返回 true 表示 1 被成功地插入。
randomizedSet
.
remove
(
2
);
// 返回 false ,表示集合中不存在 2 。
randomizedSet
.
remove
(
2
);
// 返回 false ,表示集合中不存在 2 。
randomizedSet
.
insert
(
2
);
// 向集合中插入 2 。返回 true 。集合现在包含 [1,2] 。
randomizedSet
.
insert
(
2
);
// 向集合中插入 2 。返回 true 。集合现在包含 [1,2] 。
randomizedSet
.
getRandom
();
// getRandom 应随机返回 1 或 2 。
randomizedSet
.
getRandom
();
// getRandom 应随机返回 1 或 2 。
randomizedSet
.
remove
(
1
);
// 从集合中移除 1 ,返回 true 。集合现在包含 [2] 。
randomizedSet
.
remove
(
1
);
// 从集合中移除 1 ,返回 true 。集合现在包含 [2] 。
randomizedSet
.
insert
(
2
);
// 2 已在集合中,所以返回 false 。
randomizedSet
.
insert
(
2
);
// 2 已在集合中,所以返回 false 。
randomizedSet
.
getRandom
();
// 由于 2 是集合中唯一的数字,getRandom 总是返回 2 。
randomizedSet
.
getRandom
();
// 由于 2 是集合中唯一的数字,getRandom 总是返回 2 。
```
</pre>
<p>
</p>
<p>
</p>
...
...
data/3.算法高阶/7.leetcode-回溯算法/9.37-解数独/solution.md
浏览文件 @
a73ff9b0
...
@@ -7,14 +7,14 @@
...
@@ -7,14 +7,14 @@
<li>
数字
<code>
1-9
</code>
在每一列只能出现一次。
</li>
<li>
数字
<code>
1-9
</code>
在每一列只能出现一次。
</li>
<li>
数字
<code>
1-9
</code>
在每一个以粗实线分隔的
<code>
3x3
</code>
宫内只能出现一次。(请参考示例图)
</li>
<li>
数字
<code>
1-9
</code>
在每一个以粗实线分隔的
<code>
3x3
</code>
宫内只能出现一次。(请参考示例图)
</li>
</ol>
</ol>
<p>
数独部分空格内已填入了数字,空白格用
<code>
'.'
</code>
表示。
</p>
<p>
数独部分空格内已填入了数字,空白格用
<code>
'.'
</code>
表示。
</p>
<p>
</p>
<p><strong>
示例:
</strong></p>
<img
<div
class=
"top-view__1vxA"
>
src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0037.Sudoku%20Solver/images/250px-sudoku-by-l2g-20050714svg.png" />
<div
class=
"original__bRMd"
>
<div>
<strong>
输入:
</strong>
<p><strong>
示例:
</strong></p>
<img
```
src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0037.Sudoku%20Solver/images/250px-sudoku-by-l2g-20050714svg.png" />
board =
<pre><strong>
输入:
</strong>
board =
[["5","3",".",".","7",".",".",".","."],
[["5","3",".",".","7",".",".",".","."],
["6",".",".","1","9","5",".",".","."],
["6",".",".","1","9","5",".",".","."],
[".","9","8",".",".",".",".","6","."],
[".","9","8",".",".",".",".","6","."],
...
@@ -24,7 +24,11 @@
...
@@ -24,7 +24,11 @@
[".","6",".",".",".",".","2","8","."],
[".","6",".",".",".",".","2","8","."],
[".",".",".","4","1","9",".",".","5"],
[".",".",".","4","1","9",".",".","5"],
[".",".",".",".","8",".",".","7","9"]]
[".",".",".",".","8",".",".","7","9"]]
```
<strong><br
/>
输出:
</strong>
<strong><br
/>
输出:
</strong>
```
[["5","3","4","6","7","8","9","1","2"],
[["5","3","4","6","7","8","9","1","2"],
["6","7","2","1","9","5","3","4","8"],
["6","7","2","1","9","5","3","4","8"],
["1","9","8","3","4","2","5","6","7"],
["1","9","8","3","4","2","5","6","7"],
...
@@ -34,23 +38,21 @@
...
@@ -34,23 +38,21 @@
["9","6","1","5","3","7","2","8","4"],
["9","6","1","5","3","7","2","8","4"],
["2","8","7","4","1","9","6","3","5"],
["2","8","7","4","1","9","6","3","5"],
["3","4","5","2","8","6","1","7","9"]]
["3","4","5","2","8","6","1","7","9"]]
```
<strong><br
/>
解释:
</strong>
输入的数独如上图所示,唯一有效的解决方案如下所示:
<strong><br
/>
解释:
</strong>
输入的数独如上图所示,唯一有效的解决方案如下所示:
<p>
</p>
</pre>
<img src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0037.Sudoku%20Solver/images/250px-sudoku-by-l2g-20050714_solutionsvg.png"
style="height:250px; width:250px" />
<p> </p>
<img src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0037.Sudoku%20Solver/images/250px-sudoku-by-l2g-20050714_solutionsvg.png"
<p><strong>提示:</strong></p
>
style="height:250px; width:250px" /
>
<ul>
<li><code>board.length == 9</code></li
>
<p><strong>
提示:
</strong></p
>
<li><code>board[i].length == 9</code></li
>
<ul
>
<li><code>board[i][j]</code> 是一位数字或者 <code>'.'
</code></li>
<li><code>
board.length == 9
</code></li>
<li>题目数据 <strong>保证</strong> 输入数独仅有一个解
</li>
<li><code>
board[i].length == 9
</code>
</li>
</ul
>
<li><code>
board
[
i
][
j
]
</code>
是一位数字或者
<code>
'.'
</code></li
>
</div
>
<li>
题目数据
<strong>
保证
</strong>
输入数独仅有一个解
</li
>
</div
>
</ul
>
</div>
<p>
以下
<span
style=
"color:red"
>
错误
</span>
的选项是?
</p>
<p>
以下
<span
style=
"color:red"
>
错误
</span>
的选项是?
</p>
...
...
data/3.算法高阶/8.leetcode-贪心/3.68-文本左右对齐/solution.md
浏览文件 @
a73ff9b0
# 文本左右对齐
# 文本左右对齐
<div
class=
"notranslate"
>
<p>
给定一个单词数组和一个长度
<em>
maxWidth
</em>
,重新排版单词,使其成为每行恰好有
<em>
maxWidth
</em>
个字符,且左右两端对齐的文本。
</p>
<p>
给定一个单词数组和一个长度
<em>
maxWidth
</em>
,重新排版单词,使其成为每行恰好有
<em>
maxWidth
</em>
个字符,且左右两端对齐的文本。
</p>
<p>
你应该使用“贪心算法”来放置给定的单词;也就是说,尽可能多地往每行中放置单词。必要时可用空格
<code>
' '
</code>
填充,使得每行恰好有
<em>
maxWidth
</em>
个字符。
<p>
你应该使用“贪心算法”来放置给定的单词;也就是说,尽可能多地往每行中放置单词。必要时可用空格
<code>
' '
</code>
填充,使得每行恰好有
<em>
maxWidth
</em>
个字符。
</p>
</p>
<p>
要求尽可能均匀分配单词间的空格数量。如果某一行单词间的空格不能均匀分配,则左侧放置的空格数要多于右侧的空格数。
</p>
<p>
要求尽可能均匀分配单词间的空格数量。如果某一行单词间的空格不能均匀分配,则左侧放置的空格数要多于右侧的空格数。
</p>
<p>
文本的最后一行应为左对齐,且单词之间不插入
<strong>
额外的
</strong>
空格。
</p>
<p>
文本的最后一行应为左对齐,且单词之间不插入
<strong>
额外的
</strong>
空格。
</p>
<p><strong>
说明:
</strong></p>
<p><strong>
说明:
</strong></p>
<ul>
<ul>
<li>
单词是指由非空格字符组成的字符序列。
</li>
<li>
单词是指由非空格字符组成的字符序列。
</li>
<li>
每个单词的长度大于 0,小于等于
<em>
maxWidth
</em>
。
</li>
<li>
每个单词的长度大于 0,小于等于
<em>
maxWidth
</em>
。
</li>
<li>
输入单词数组
<code>
words
</code>
至少包含一个单词。
</li>
<li>
输入单词数组
<code>
words
</code>
至少包含一个单词。
</li>
</ul>
</ul>
<p><strong>
示例:
</strong></p>
<p><strong>
示例:
</strong></p>
<pre><strong>
输入:
</strong>
<pre><strong>
输入:
</strong>
words = ["This", "is", "an", "example", "of", "text", "justification."]
words = ["This", "is", "an", "example", "of", "text", "justification."]
maxWidth = 16
maxWidth = 16
<strong><br
/>
输出:
</strong>
<strong><br
/>
输出:
</strong>
[
[
"This
is
an",
"This
is
an",
"example
of text",
"example
of text",
"justification.
"
"justification.
"
]
]
</pre>
</pre>
<p><strong>
示例
2:
</strong></p>
<p><strong>
示例
2:
</strong></p>
<pre><strong>
输入:
</strong>
<pre><strong>
输入:
</strong>
words = ["What","must","be","acknowledgment","shall","be"]
words = ["What","must","be","acknowledgment","shall","be"]
maxWidth = 16
maxWidth = 16
<strong><br
/>
输出:
</strong>
<strong><br
/>
输出:
</strong>
[
[
"What
must
be",
"What
must
be",
"acknowledgment
",
"acknowledgment
",
"shall be
"
"shall be
"
]
]
<strong><br
/>
解释:
</strong>
注意最后一行的格式应为 "shall be " 而不是 "shall be"
<strong><br
/>
解释:
</strong>
注意最后一行的格式应为 "shall be " 而不是 "shall be"
因为最后一行应为左对齐,而不是左右两端对齐,第二行同样为左对齐,这是因为这行只包含一个单词。
因为最后一行应为左对齐,而不是左右两端对齐,第二行同样为左对齐,这是因为这行只包含一个单词。
</pre>
</pre>
<p><strong>
示例
3:
</strong></p>
<p><strong>
示例
3:
</strong></p>
<pre><strong>
输入:
</strong>
<pre><strong>
输入:
</strong>
words = ["Science","is","what","we","understand","well","enough","to","explain",
words = ["Science","is","what","we","understand","well","enough","to","explain",
"to","a","computer.","Art","is","everything","else","we","do"]
"to","a","computer.","Art","is","everything","else","we","do"]
maxWidth = 20
maxWidth = 20
<strong><br
/>
输出:
</strong>
<strong><br
/>
输出:
</strong>
[
[
"Science
is
what we",
"Science
is
what we",
"understand
well",
"understand
well",
"enough to explain to",
"enough to explain to",
"a
computer.
Art is",
"a
computer.
Art is",
"everything
else
we",
"everything
else
we",
"do
"
"do
"
]
]
</pre>
</pre>
</div>
<p>
以下
<span
style=
"color:red"
>
错误
</span>
的选项是?
</p>
<p>
以下
<span
style=
"color:red"
>
错误
</span>
的选项是?
</p>
## aop
## aop
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录