Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN 技术社区
skill_tree_algorithm
提交
ceaae444
S
skill_tree_algorithm
项目概览
CSDN 技术社区
/
skill_tree_algorithm
通知
9
Star
8
Fork
1
代码
文件
提交
分支
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看板
提交
ceaae444
编写于
11月 09, 2021
作者:
F
feilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug
上级
9f06a56f
变更
204
隐藏空白更改
内联
并排
Showing
204 changed file
with
1905 addition
and
0 deletion
+1905
-0
data/1.算法初阶/1.蓝桥杯-基础/100.第39级台阶/solution.md
data/1.算法初阶/1.蓝桥杯-基础/100.第39级台阶/solution.md
+9
-0
data/1.算法初阶/1.蓝桥杯-基础/104.9数算式/solution.md
data/1.算法初阶/1.蓝桥杯-基础/104.9数算式/solution.md
+9
-0
data/1.算法初阶/1.蓝桥杯-基础/106.错误票据/desc.md
data/1.算法初阶/1.蓝桥杯-基础/106.错误票据/desc.md
+8
-0
data/1.算法初阶/1.蓝桥杯-基础/106.错误票据/solution.md
data/1.算法初阶/1.蓝桥杯-基础/106.错误票据/solution.md
+16
-0
data/1.算法初阶/1.蓝桥杯-基础/112.大数乘法/solution.md
data/1.算法初阶/1.蓝桥杯-基础/112.大数乘法/solution.md
+9
-0
data/1.算法初阶/1.蓝桥杯-基础/114.大衍数列/solution.md
data/1.算法初阶/1.蓝桥杯-基础/114.大衍数列/solution.md
+9
-0
data/1.算法初阶/1.蓝桥杯-基础/120.成绩统计/desc.md
data/1.算法初阶/1.蓝桥杯-基础/120.成绩统计/desc.md
+5
-0
data/1.算法初阶/1.蓝桥杯-基础/120.成绩统计/solution.md
data/1.算法初阶/1.蓝桥杯-基础/120.成绩统计/solution.md
+14
-0
data/1.算法初阶/1.蓝桥杯-基础/126.比酒量/solution.md
data/1.算法初阶/1.蓝桥杯-基础/126.比酒量/solution.md
+9
-0
data/1.算法初阶/1.蓝桥杯-基础/134.第几天/desc.md
data/1.算法初阶/1.蓝桥杯-基础/134.第几天/desc.md
+5
-0
data/1.算法初阶/1.蓝桥杯-基础/134.第几天/solution.md
data/1.算法初阶/1.蓝桥杯-基础/134.第几天/solution.md
+14
-0
data/1.算法初阶/1.蓝桥杯-基础/135.斐波那契/desc.md
data/1.算法初阶/1.蓝桥杯-基础/135.斐波那契/desc.md
+7
-0
data/1.算法初阶/1.蓝桥杯-基础/135.斐波那契/solution.md
data/1.算法初阶/1.蓝桥杯-基础/135.斐波那契/solution.md
+15
-0
data/1.算法初阶/1.蓝桥杯-基础/149.方阵转置/desc.md
data/1.算法初阶/1.蓝桥杯-基础/149.方阵转置/desc.md
+5
-0
data/1.算法初阶/1.蓝桥杯-基础/149.方阵转置/solution.md
data/1.算法初阶/1.蓝桥杯-基础/149.方阵转置/solution.md
+14
-0
data/1.算法初阶/1.蓝桥杯-基础/158.倍数问题/desc.md
data/1.算法初阶/1.蓝桥杯-基础/158.倍数问题/desc.md
+7
-0
data/1.算法初阶/1.蓝桥杯-基础/158.倍数问题/solution.md
data/1.算法初阶/1.蓝桥杯-基础/158.倍数问题/solution.md
+15
-0
data/1.算法初阶/1.蓝桥杯-基础/24.乘积尾零/solution.md
data/1.算法初阶/1.蓝桥杯-基础/24.乘积尾零/solution.md
+9
-0
data/1.算法初阶/1.蓝桥杯-基础/3.分数/solution.md
data/1.算法初阶/1.蓝桥杯-基础/3.分数/solution.md
+9
-0
data/1.算法初阶/1.蓝桥杯-基础/4.等差素数列/desc.md
data/1.算法初阶/1.蓝桥杯-基础/4.等差素数列/desc.md
+1
-0
data/1.算法初阶/1.蓝桥杯-基础/4.等差素数列/solution.md
data/1.算法初阶/1.蓝桥杯-基础/4.等差素数列/solution.md
+10
-0
data/1.算法初阶/1.蓝桥杯-基础/40.成绩分析/desc.md
data/1.算法初阶/1.蓝桥杯-基础/40.成绩分析/desc.md
+5
-0
data/1.算法初阶/1.蓝桥杯-基础/40.成绩分析/solution.md
data/1.算法初阶/1.蓝桥杯-基础/40.成绩分析/solution.md
+14
-0
data/1.算法初阶/1.蓝桥杯-基础/41.乘积最大/desc.md
data/1.算法初阶/1.蓝桥杯-基础/41.乘积最大/desc.md
+8
-0
data/1.算法初阶/1.蓝桥杯-基础/41.乘积最大/solution.md
data/1.算法初阶/1.蓝桥杯-基础/41.乘积最大/solution.md
+16
-0
data/1.算法初阶/1.蓝桥杯-基础/67.猜年龄/solution.md
data/1.算法初阶/1.蓝桥杯-基础/67.猜年龄/solution.md
+9
-0
data/1.算法初阶/1.蓝桥杯-基础/69.递增三元组/desc.md
data/1.算法初阶/1.蓝桥杯-基础/69.递增三元组/desc.md
+4
-0
data/1.算法初阶/1.蓝桥杯-基础/69.递增三元组/solution.md
data/1.算法初阶/1.蓝桥杯-基础/69.递增三元组/solution.md
+13
-0
data/1.算法初阶/1.蓝桥杯-基础/77.第几个幸运数/solution.md
data/1.算法初阶/1.蓝桥杯-基础/77.第几个幸运数/solution.md
+9
-0
data/1.算法初阶/1.蓝桥杯-基础/88.次数差/desc.md
data/1.算法初阶/1.蓝桥杯-基础/88.次数差/desc.md
+9
-0
data/1.算法初阶/1.蓝桥杯-基础/88.次数差/solution.md
data/1.算法初阶/1.蓝桥杯-基础/88.次数差/solution.md
+17
-0
data/1.算法初阶/1.蓝桥杯-基础/99.猜字母/solution.md
data/1.算法初阶/1.蓝桥杯-基础/99.猜字母/solution.md
+9
-0
data/1.算法初阶/2.蓝桥杯-字符串/92.单词分析/desc.md
data/1.算法初阶/2.蓝桥杯-字符串/92.单词分析/desc.md
+8
-0
data/1.算法初阶/2.蓝桥杯-字符串/92.单词分析/solution.md
data/1.算法初阶/2.蓝桥杯-字符串/92.单词分析/solution.md
+17
-0
data/1.算法初阶/2.蓝桥杯-字符串/97.分类计数/desc.md
data/1.算法初阶/2.蓝桥杯-字符串/97.分类计数/desc.md
+6
-0
data/1.算法初阶/2.蓝桥杯-字符串/97.分类计数/solution.md
data/1.算法初阶/2.蓝桥杯-字符串/97.分类计数/solution.md
+15
-0
data/1.算法初阶/2.蓝桥杯-字符串/98.翻硬币/desc.md
data/1.算法初阶/2.蓝桥杯-字符串/98.翻硬币/desc.md
+8
-0
data/1.算法初阶/2.蓝桥杯-字符串/98.翻硬币/solution.md
data/1.算法初阶/2.蓝桥杯-字符串/98.翻硬币/solution.md
+16
-0
data/1.算法初阶/3.蓝桥杯-递归/143.带分数/desc.md
data/1.算法初阶/3.蓝桥杯-递归/143.带分数/desc.md
+8
-0
data/1.算法初阶/3.蓝桥杯-递归/143.带分数/solution.md
data/1.算法初阶/3.蓝桥杯-递归/143.带分数/solution.md
+16
-0
data/1.算法初阶/3.蓝桥杯-递归/163.等差数列/desc.md
data/1.算法初阶/3.蓝桥杯-递归/163.等差数列/desc.md
+7
-0
data/1.算法初阶/3.蓝桥杯-递归/163.等差数列/solution.md
data/1.算法初阶/3.蓝桥杯-递归/163.等差数列/solution.md
+15
-0
data/1.算法初阶/3.蓝桥杯-递归/35.抽签/desc.md
data/1.算法初阶/3.蓝桥杯-递归/35.抽签/desc.md
+4
-0
data/1.算法初阶/3.蓝桥杯-递归/35.抽签/solution.md
data/1.算法初阶/3.蓝桥杯-递归/35.抽签/solution.md
+13
-0
data/1.算法初阶/3.蓝桥杯-递归/58.打印图形/solution.md
data/1.算法初阶/3.蓝桥杯-递归/58.打印图形/solution.md
+9
-0
data/1.算法初阶/4.蓝桥杯-堆栈队列链表/124.堆的计数/desc.md
data/1.算法初阶/4.蓝桥杯-堆栈队列链表/124.堆的计数/desc.md
+6
-0
data/1.算法初阶/4.蓝桥杯-堆栈队列链表/124.堆的计数/solution.md
data/1.算法初阶/4.蓝桥杯-堆栈队列链表/124.堆的计数/solution.md
+15
-0
data/1.算法初阶/6.蓝桥杯-模拟/137.夺冠概率/solution.md
data/1.算法初阶/6.蓝桥杯-模拟/137.夺冠概率/solution.md
+9
-0
data/1.算法初阶/6.蓝桥杯-模拟/14.方程整数解/desc.md
data/1.算法初阶/6.蓝桥杯-模拟/14.方程整数解/desc.md
+5
-0
data/1.算法初阶/6.蓝桥杯-模拟/14.方程整数解/solution.md
data/1.算法初阶/6.蓝桥杯-模拟/14.方程整数解/solution.md
+14
-0
data/1.算法初阶/6.蓝桥杯-模拟/162.7段码/desc.md
data/1.算法初阶/6.蓝桥杯-模拟/162.7段码/desc.md
+1
-0
data/1.算法初阶/6.蓝桥杯-模拟/162.7段码/solution.md
data/1.算法初阶/6.蓝桥杯-模拟/162.7段码/solution.md
+10
-0
data/1.算法初阶/6.蓝桥杯-模拟/175.颠倒的价牌/solution.md
data/1.算法初阶/6.蓝桥杯-模拟/175.颠倒的价牌/solution.md
+9
-0
data/1.算法初阶/6.蓝桥杯-模拟/187.承压计算/solution.md
data/1.算法初阶/6.蓝桥杯-模拟/187.承压计算/solution.md
+9
-0
data/1.算法初阶/6.蓝桥杯-模拟/23.放棋子/solution.md
data/1.算法初阶/6.蓝桥杯-模拟/23.放棋子/solution.md
+9
-0
data/1.算法初阶/6.蓝桥杯-模拟/28.分巧克力/desc.md
data/1.算法初阶/6.蓝桥杯-模拟/28.分巧克力/desc.md
+4
-0
data/1.算法初阶/6.蓝桥杯-模拟/28.分巧克力/solution.md
data/1.算法初阶/6.蓝桥杯-模拟/28.分巧克力/solution.md
+13
-0
data/1.算法初阶/6.蓝桥杯-模拟/53.等腰三角形/desc.md
data/1.算法初阶/6.蓝桥杯-模拟/53.等腰三角形/desc.md
+9
-0
data/1.算法初阶/6.蓝桥杯-模拟/53.等腰三角形/solution.md
data/1.算法初阶/6.蓝桥杯-模拟/53.等腰三角形/solution.md
+18
-0
data/1.算法初阶/6.蓝桥杯-模拟/54.分糖果/desc.md
data/1.算法初阶/6.蓝桥杯-模拟/54.分糖果/desc.md
+6
-0
data/1.算法初阶/6.蓝桥杯-模拟/54.分糖果/solution.md
data/1.算法初阶/6.蓝桥杯-模拟/54.分糖果/solution.md
+14
-0
data/1.算法初阶/6.蓝桥杯-模拟/63.方格填数/solution.md
data/1.算法初阶/6.蓝桥杯-模拟/63.方格填数/solution.md
+9
-0
data/1.算法初阶/7.蓝桥杯-搜索/121.超级胶水/solution.md
data/1.算法初阶/7.蓝桥杯-搜索/121.超级胶水/solution.md
+9
-0
data/1.算法初阶/7.蓝桥杯-搜索/156.凑算式/solution.md
data/1.算法初阶/7.蓝桥杯-搜索/156.凑算式/solution.md
+9
-0
data/1.算法初阶/7.蓝桥杯-搜索/188.大臣的旅费/desc.md
data/1.算法初阶/7.蓝桥杯-搜索/188.大臣的旅费/desc.md
+7
-0
data/1.算法初阶/7.蓝桥杯-搜索/188.大臣的旅费/solution.md
data/1.算法初阶/7.蓝桥杯-搜索/188.大臣的旅费/solution.md
+15
-0
data/1.算法初阶/7.蓝桥杯-搜索/51.分配口罩/solution.md
data/1.算法初阶/7.蓝桥杯-搜索/51.分配口罩/solution.md
+9
-0
data/1.算法初阶/7.蓝桥杯-搜索/6.搭积木/solution.md
data/1.算法初阶/7.蓝桥杯-搜索/6.搭积木/solution.md
+9
-0
data/1.算法初阶/7.蓝桥杯-搜索/65.方格分割/solution.md
data/1.算法初阶/7.蓝桥杯-搜索/65.方格分割/solution.md
+9
-0
data/1.算法初阶/9.蓝桥杯-动态规划/117.地宫取宝/desc.md
data/1.算法初阶/9.蓝桥杯-动态规划/117.地宫取宝/desc.md
+8
-0
data/1.算法初阶/9.蓝桥杯-动态规划/117.地宫取宝/solution.md
data/1.算法初阶/9.蓝桥杯-动态规划/117.地宫取宝/solution.md
+16
-0
data/1.算法初阶/9.蓝桥杯-动态规划/91.测试次数/solution.md
data/1.算法初阶/9.蓝桥杯-动态规划/91.测试次数/solution.md
+9
-0
data/2.算法中阶/1.leetcode-数组/0.两数之和/solution.md
data/2.算法中阶/1.leetcode-数组/0.两数之和/solution.md
+9
-0
data/2.算法中阶/1.leetcode-数组/14.三数之和/solution.md
data/2.算法中阶/1.leetcode-数组/14.三数之和/solution.md
+9
-0
data/2.算法中阶/1.leetcode-数组/17.四数之和/solution.md
data/2.算法中阶/1.leetcode-数组/17.四数之和/solution.md
+9
-0
data/2.算法中阶/1.leetcode-数组/3.寻找两个正序数组的中位数/solution.md
data/2.算法中阶/1.leetcode-数组/3.寻找两个正序数组的中位数/solution.md
+9
-0
data/2.算法中阶/1.leetcode-数组/32.搜索旋转排序数组/solution.md
data/2.算法中阶/1.leetcode-数组/32.搜索旋转排序数组/solution.md
+9
-0
data/2.算法中阶/1.leetcode-数组/33.在排序数组中查找元素的第一个和最后一个位置/solution.md
...2.算法中阶/1.leetcode-数组/33.在排序数组中查找元素的第一个和最后一个位置/solution.md
+9
-0
data/2.算法中阶/1.leetcode-数组/34.搜索插入位置/solution.md
data/2.算法中阶/1.leetcode-数组/34.搜索插入位置/solution.md
+9
-0
data/2.算法中阶/1.leetcode-数组/47.旋转图像/solution.md
data/2.算法中阶/1.leetcode-数组/47.旋转图像/solution.md
+9
-0
data/2.算法中阶/1.leetcode-数组/53.螺旋矩阵/solution.md
data/2.算法中阶/1.leetcode-数组/53.螺旋矩阵/solution.md
+9
-0
data/2.算法中阶/1.leetcode-数组/55.合并区间/solution.md
data/2.算法中阶/1.leetcode-数组/55.合并区间/solution.md
+9
-0
data/2.算法中阶/1.leetcode-数组/56.插入区间/solution.md
data/2.算法中阶/1.leetcode-数组/56.插入区间/solution.md
+9
-0
data/2.算法中阶/1.leetcode-数组/58.螺旋矩阵 II/solution.md
data/2.算法中阶/1.leetcode-数组/58.螺旋矩阵 II/solution.md
+9
-0
data/2.算法中阶/1.leetcode-数组/72.矩阵置零/solution.md
data/2.算法中阶/1.leetcode-数组/72.矩阵置零/solution.md
+9
-0
data/2.算法中阶/1.leetcode-数组/73.搜索二维矩阵/solution.md
data/2.算法中阶/1.leetcode-数组/73.搜索二维矩阵/solution.md
+9
-0
data/2.算法中阶/1.leetcode-数组/77.子集/solution.md
data/2.算法中阶/1.leetcode-数组/77.子集/solution.md
+9
-0
data/2.算法中阶/1.leetcode-数组/79.删除有序数组中的重复项 II/solution.md
data/2.算法中阶/1.leetcode-数组/79.删除有序数组中的重复项 II/solution.md
+9
-0
data/2.算法中阶/1.leetcode-数组/80.搜索旋转排序数组 II/solution.md
data/2.算法中阶/1.leetcode-数组/80.搜索旋转排序数组 II/solution.md
+9
-0
data/2.算法中阶/2.leetcode-链表/1.两数相加/solution.md
data/2.算法中阶/2.leetcode-链表/1.两数相加/solution.md
+9
-0
data/2.算法中阶/2.leetcode-链表/18.删除链表的倒数第 N 个结点/solution.md
data/2.算法中阶/2.leetcode-链表/18.删除链表的倒数第 N 个结点/solution.md
+9
-0
data/2.算法中阶/2.leetcode-链表/20.合并两个有序链表/solution.md
data/2.算法中阶/2.leetcode-链表/20.合并两个有序链表/solution.md
+9
-0
data/2.算法中阶/2.leetcode-链表/22.合并K个升序链表/solution.md
data/2.算法中阶/2.leetcode-链表/22.合并K个升序链表/solution.md
+9
-0
data/2.算法中阶/2.leetcode-链表/23.两两交换链表中的节点/solution.md
data/2.算法中阶/2.leetcode-链表/23.两两交换链表中的节点/solution.md
+9
-0
data/2.算法中阶/2.leetcode-链表/24.K 个一组翻转链表/solution.md
data/2.算法中阶/2.leetcode-链表/24.K 个一组翻转链表/solution.md
+9
-0
data/2.算法中阶/2.leetcode-链表/81.删除排序链表中的重复元素 II/solution.md
data/2.算法中阶/2.leetcode-链表/81.删除排序链表中的重复元素 II/solution.md
+9
-0
data/2.算法中阶/2.leetcode-链表/82.删除排序链表中的重复元素/solution.md
data/2.算法中阶/2.leetcode-链表/82.删除排序链表中的重复元素/solution.md
+9
-0
data/2.算法中阶/2.leetcode-链表/85.分隔链表/solution.md
data/2.算法中阶/2.leetcode-链表/85.分隔链表/solution.md
+9
-0
data/2.算法中阶/2.leetcode-链表/91.反转链表 II/solution.md
data/2.算法中阶/2.leetcode-链表/91.反转链表 II/solution.md
+9
-0
data/2.算法中阶/3.leetcode-字符串/13.最长公共前缀/solution.md
data/2.算法中阶/3.leetcode-字符串/13.最长公共前缀/solution.md
+9
-0
data/2.算法中阶/3.leetcode-字符串/2.无重复字符的最长子串/solution.md
data/2.算法中阶/3.leetcode-字符串/2.无重复字符的最长子串/solution.md
+9
-0
data/2.算法中阶/3.leetcode-字符串/27.实现 strStr()/solution.md
data/2.算法中阶/3.leetcode-字符串/27.实现 strStr()/solution.md
+9
-0
data/2.算法中阶/3.leetcode-字符串/37.外观数列/solution.md
data/2.算法中阶/3.leetcode-字符串/37.外观数列/solution.md
+9
-0
data/2.算法中阶/3.leetcode-字符串/42.字符串相乘/solution.md
data/2.算法中阶/3.leetcode-字符串/42.字符串相乘/solution.md
+9
-0
data/2.算法中阶/3.leetcode-字符串/5.Z 字形变换/solution.md
data/2.算法中阶/3.leetcode-字符串/5.Z 字形变换/solution.md
+9
-0
data/2.算法中阶/3.leetcode-字符串/57.最后一个单词的长度/solution.md
data/2.算法中阶/3.leetcode-字符串/57.最后一个单词的长度/solution.md
+9
-0
data/2.算法中阶/3.leetcode-字符串/64.有效数字/solution.md
data/2.算法中阶/3.leetcode-字符串/64.有效数字/solution.md
+9
-0
data/2.算法中阶/3.leetcode-字符串/7.字符串转换整数 (atoi)/solution.md
data/2.算法中阶/3.leetcode-字符串/7.字符串转换整数 (atoi)/solution.md
+9
-0
data/2.算法中阶/3.leetcode-字符串/92.复原 IP 地址/solution.md
data/2.算法中阶/3.leetcode-字符串/92.复原 IP 地址/solution.md
+9
-0
data/2.算法中阶/3.leetcode-字符串/96.交错字符串/solution.md
data/2.算法中阶/3.leetcode-字符串/96.交错字符串/solution.md
+9
-0
data/2.算法中阶/4.leetcode-栈与队列/149.逆波兰表达式求值/solution.md
data/2.算法中阶/4.leetcode-栈与队列/149.逆波兰表达式求值/solution.md
+9
-0
data/2.算法中阶/4.leetcode-栈与队列/154.最小栈/solution.md
data/2.算法中阶/4.leetcode-栈与队列/154.最小栈/solution.md
+9
-0
data/2.算法中阶/4.leetcode-栈与队列/19.有效的括号/solution.md
data/2.算法中阶/4.leetcode-栈与队列/19.有效的括号/solution.md
+9
-0
data/2.算法中阶/4.leetcode-栈与队列/217.天际线问题/solution.md
data/2.算法中阶/4.leetcode-栈与队列/217.天际线问题/solution.md
+9
-0
data/2.算法中阶/4.leetcode-栈与队列/223.基本计算器/solution.md
data/2.算法中阶/4.leetcode-栈与队列/223.基本计算器/solution.md
+9
-0
data/2.算法中阶/4.leetcode-栈与队列/226.基本计算器 II/solution.md
data/2.算法中阶/4.leetcode-栈与队列/226.基本计算器 II/solution.md
+9
-0
data/2.算法中阶/4.leetcode-栈与队列/31.最长有效括号/solution.md
data/2.算法中阶/4.leetcode-栈与队列/31.最长有效括号/solution.md
+9
-0
data/2.算法中阶/4.leetcode-栈与队列/41.接雨水/solution.md
data/2.算法中阶/4.leetcode-栈与队列/41.接雨水/solution.md
+9
-0
data/2.算法中阶/4.leetcode-栈与队列/70.简化路径/solution.md
data/2.算法中阶/4.leetcode-栈与队列/70.简化路径/solution.md
+9
-0
data/2.算法中阶/4.leetcode-栈与队列/83.柱状图中最大的矩形/solution.md
data/2.算法中阶/4.leetcode-栈与队列/83.柱状图中最大的矩形/solution.md
+9
-0
data/2.算法中阶/5.leetcode-排序算法/163.最大间距/solution.md
data/2.算法中阶/5.leetcode-排序算法/163.最大间距/solution.md
+9
-0
data/2.算法中阶/5.leetcode-排序算法/273.H 指数/solution.md
data/2.算法中阶/5.leetcode-排序算法/273.H 指数/solution.md
+9
-0
data/2.算法中阶/5.leetcode-排序算法/314.计算右侧小于当前元素的个数/solution.md
data/2.算法中阶/5.leetcode-排序算法/314.计算右侧小于当前元素的个数/solution.md
+9
-0
data/2.算法中阶/5.leetcode-排序算法/323.摆动排序 II/solution.md
data/2.算法中阶/5.leetcode-排序算法/323.摆动排序 II/solution.md
+9
-0
data/2.算法中阶/5.leetcode-排序算法/326.区间和的个数/solution.md
data/2.算法中阶/5.leetcode-排序算法/326.区间和的个数/solution.md
+9
-0
data/2.算法中阶/5.leetcode-排序算法/346.前 K 个高频元素/solution.md
data/2.算法中阶/5.leetcode-排序算法/346.前 K 个高频元素/solution.md
+9
-0
data/2.算法中阶/5.leetcode-排序算法/353.俄罗斯套娃信封问题/solution.md
data/2.算法中阶/5.leetcode-排序算法/353.俄罗斯套娃信封问题/solution.md
+9
-0
data/2.算法中阶/5.leetcode-排序算法/377.有序矩阵中第 K 小的元素/solution.md
data/2.算法中阶/5.leetcode-排序算法/377.有序矩阵中第 K 小的元素/solution.md
+9
-0
data/2.算法中阶/5.leetcode-排序算法/492.翻转对/solution.md
data/2.算法中阶/5.leetcode-排序算法/492.翻转对/solution.md
+9
-0
data/2.算法中阶/5.leetcode-排序算法/911.排序数组/solution.md
data/2.算法中阶/5.leetcode-排序算法/911.排序数组/solution.md
+12
-0
data/2.算法中阶/6.leetcode-双指针/10.盛最多水的容器/solution.md
data/2.算法中阶/6.leetcode-双指针/10.盛最多水的容器/solution.md
+9
-0
data/2.算法中阶/6.leetcode-双指针/140.环形链表/solution.md
data/2.算法中阶/6.leetcode-双指针/140.环形链表/solution.md
+9
-0
data/2.算法中阶/6.leetcode-双指针/141.环形链表 II/solution.md
data/2.算法中阶/6.leetcode-双指针/141.环形链表 II/solution.md
+9
-0
data/2.算法中阶/6.leetcode-双指针/15.最接近的三数之和/solution.md
data/2.算法中阶/6.leetcode-双指针/15.最接近的三数之和/solution.md
+9
-0
data/2.算法中阶/6.leetcode-双指针/25.删除有序数组中的重复项/solution.md
data/2.算法中阶/6.leetcode-双指针/25.删除有序数组中的重复项/solution.md
+9
-0
data/2.算法中阶/6.leetcode-双指针/26.移除元素/solution.md
data/2.算法中阶/6.leetcode-双指针/26.移除元素/solution.md
+9
-0
data/2.算法中阶/6.leetcode-双指针/30.下一个排列/solution.md
data/2.算法中阶/6.leetcode-双指针/30.下一个排列/solution.md
+9
-0
data/2.算法中阶/6.leetcode-双指针/60.旋转链表/solution.md
data/2.算法中阶/6.leetcode-双指针/60.旋转链表/solution.md
+9
-0
data/2.算法中阶/6.leetcode-双指针/74.颜色分类/solution.md
data/2.算法中阶/6.leetcode-双指针/74.颜色分类/solution.md
+9
-0
data/2.算法中阶/6.leetcode-双指针/87.合并两个有序数组/solution.md
data/2.算法中阶/6.leetcode-双指针/87.合并两个有序数组/solution.md
+9
-0
data/3.算法高阶/1.leetcode-树/123.二叉树中的最大路径和/solution.md
data/3.算法高阶/1.leetcode-树/123.二叉树中的最大路径和/solution.md
+9
-0
data/3.算法高阶/1.leetcode-树/93.二叉树的中序遍历/solution.md
data/3.算法高阶/1.leetcode-树/93.二叉树的中序遍历/solution.md
+9
-0
data/3.算法高阶/1.leetcode-树/94.不同的二叉搜索树 II/solution.md
data/3.算法高阶/1.leetcode-树/94.不同的二叉搜索树 II/solution.md
+9
-0
data/3.算法高阶/1.leetcode-树/95.不同的二叉搜索树/solution.md
data/3.算法高阶/1.leetcode-树/95.不同的二叉搜索树/solution.md
+9
-0
data/3.算法高阶/1.leetcode-树/97.验证二叉搜索树/solution.md
data/3.算法高阶/1.leetcode-树/97.验证二叉搜索树/solution.md
+9
-0
data/3.算法高阶/1.leetcode-树/98.恢复二叉搜索树/solution.md
data/3.算法高阶/1.leetcode-树/98.恢复二叉搜索树/solution.md
+9
-0
data/3.算法高阶/1.leetcode-树/99.相同的树/solution.md
data/3.算法高阶/1.leetcode-树/99.相同的树/solution.md
+9
-0
data/3.算法高阶/2.leetcode-哈希表/204.同构字符串/solution.md
data/3.算法高阶/2.leetcode-哈希表/204.同构字符串/solution.md
+9
-0
data/3.算法高阶/2.leetcode-哈希表/29.串联所有单词的子串/solution.md
data/3.算法高阶/2.leetcode-哈希表/29.串联所有单词的子串/solution.md
+9
-0
data/3.算法高阶/2.leetcode-哈希表/35.有效的数独/solution.md
data/3.算法高阶/2.leetcode-哈希表/35.有效的数独/solution.md
+9
-0
data/3.算法高阶/2.leetcode-哈希表/40.缺失的第一个正数/solution.md
data/3.算法高阶/2.leetcode-哈希表/40.缺失的第一个正数/solution.md
+9
-0
data/3.算法高阶/2.leetcode-哈希表/48.字母异位词分组/solution.md
data/3.算法高阶/2.leetcode-哈希表/48.字母异位词分组/solution.md
+9
-0
data/3.算法高阶/2.leetcode-哈希表/75.最小覆盖子串/solution.md
data/3.算法高阶/2.leetcode-哈希表/75.最小覆盖子串/solution.md
+9
-0
data/3.算法高阶/3.leetcode-图与搜索/132.克隆图/solution.md
data/3.算法高阶/3.leetcode-图与搜索/132.克隆图/solution.md
+9
-0
data/3.算法高阶/3.leetcode-图与搜索/206.课程表/solution.md
data/3.算法高阶/3.leetcode-图与搜索/206.课程表/solution.md
+9
-0
data/3.算法高阶/3.leetcode-图与搜索/209.课程表 II/solution.md
data/3.算法高阶/3.leetcode-图与搜索/209.课程表 II/solution.md
+9
-0
data/3.算法高阶/3.leetcode-图与搜索/328.矩阵中的最长递增路径/solution.md
data/3.算法高阶/3.leetcode-图与搜索/328.矩阵中的最长递增路径/solution.md
+9
-0
data/3.算法高阶/3.leetcode-图与搜索/331.重新安排行程/solution.md
data/3.算法高阶/3.leetcode-图与搜索/331.重新安排行程/solution.md
+9
-0
data/3.算法高阶/3.leetcode-图与搜索/76.组合/solution.md
data/3.算法高阶/3.leetcode-图与搜索/76.组合/solution.md
+9
-0
data/3.算法高阶/3.leetcode-图与搜索/78.单词搜索/solution.md
data/3.算法高阶/3.leetcode-图与搜索/78.单词搜索/solution.md
+9
-0
data/3.算法高阶/4.leetcode-数学/11.整数转罗马数字/solution.md
data/3.算法高阶/4.leetcode-数学/11.整数转罗马数字/solution.md
+9
-0
data/3.算法高阶/4.leetcode-数学/12.罗马数字转整数/solution.md
data/3.算法高阶/4.leetcode-数学/12.罗马数字转整数/solution.md
+9
-0
data/3.算法高阶/4.leetcode-数学/28.两数相除/solution.md
data/3.算法高阶/4.leetcode-数学/28.两数相除/solution.md
+9
-0
data/3.算法高阶/4.leetcode-数学/49.Pow(x, n)/solution.md
data/3.算法高阶/4.leetcode-数学/49.Pow(x, n)/solution.md
+9
-0
data/3.算法高阶/4.leetcode-数学/59.排列序列/solution.md
data/3.算法高阶/4.leetcode-数学/59.排列序列/solution.md
+9
-0
data/3.算法高阶/4.leetcode-数学/6.整数反转/solution.md
data/3.算法高阶/4.leetcode-数学/6.整数反转/solution.md
+9
-0
data/3.算法高阶/4.leetcode-数学/65.加一/solution.md
data/3.算法高阶/4.leetcode-数学/65.加一/solution.md
+9
-0
data/3.算法高阶/4.leetcode-数学/66.二进制求和/solution.md
data/3.算法高阶/4.leetcode-数学/66.二进制求和/solution.md
+9
-0
data/3.算法高阶/4.leetcode-数学/68.x 的平方根/solution.md
data/3.算法高阶/4.leetcode-数学/68.x 的平方根/solution.md
+9
-0
data/3.算法高阶/4.leetcode-数学/8.回文数/solution.md
data/3.算法高阶/4.leetcode-数学/8.回文数/solution.md
+9
-0
data/3.算法高阶/5.leetcode-设计/145.LRU 缓存机制/solution.md
data/3.算法高阶/5.leetcode-设计/145.LRU 缓存机制/solution.md
+9
-0
data/3.算法高阶/5.leetcode-设计/354.设计推特/solution.md
data/3.算法高阶/5.leetcode-设计/354.设计推特/solution.md
+9
-0
data/3.算法高阶/5.leetcode-设计/379.O(1) 时间插入、删除和获取随机元素/solution.md
.../3.算法高阶/5.leetcode-设计/379.O(1) 时间插入、删除和获取随机元素/solution.md
+9
-0
data/3.算法高阶/5.leetcode-设计/380.O(1) 时间插入、删除和获取随机元素 - 允许重复/solution.md
.../5.leetcode-设计/380.O(1) 时间插入、删除和获取随机元素 - 允许重复/solution.md
+9
-0
data/3.算法高阶/5.leetcode-设计/459.LFU 缓存/solution.md
data/3.算法高阶/5.leetcode-设计/459.LFU 缓存/solution.md
+9
-0
data/3.算法高阶/6.leetcode-动态规划/21.括号生成/solution.md
data/3.算法高阶/6.leetcode-动态规划/21.括号生成/solution.md
+9
-0
data/3.算法高阶/6.leetcode-动态规划/4.最长回文子串/solution.md
data/3.算法高阶/6.leetcode-动态规划/4.最长回文子串/solution.md
+9
-0
data/3.算法高阶/6.leetcode-动态规划/43.通配符匹配/solution.md
data/3.算法高阶/6.leetcode-动态规划/43.通配符匹配/solution.md
+9
-0
data/3.算法高阶/6.leetcode-动态规划/52.最大子序和/solution.md
data/3.算法高阶/6.leetcode-动态规划/52.最大子序和/solution.md
+9
-0
data/3.算法高阶/6.leetcode-动态规划/61.不同路径/solution.md
data/3.算法高阶/6.leetcode-动态规划/61.不同路径/solution.md
+9
-0
data/3.算法高阶/6.leetcode-动态规划/62.不同路径 II/solution.md
data/3.算法高阶/6.leetcode-动态规划/62.不同路径 II/solution.md
+9
-0
data/3.算法高阶/6.leetcode-动态规划/63.最小路径和/solution.md
data/3.算法高阶/6.leetcode-动态规划/63.最小路径和/solution.md
+9
-0
data/3.算法高阶/6.leetcode-动态规划/69.爬楼梯/solution.md
data/3.算法高阶/6.leetcode-动态规划/69.爬楼梯/solution.md
+9
-0
data/3.算法高阶/6.leetcode-动态规划/71.编辑距离/solution.md
data/3.算法高阶/6.leetcode-动态规划/71.编辑距离/solution.md
+9
-0
data/3.算法高阶/6.leetcode-动态规划/84.最大矩形/solution.md
data/3.算法高阶/6.leetcode-动态规划/84.最大矩形/solution.md
+9
-0
data/3.算法高阶/6.leetcode-动态规划/86.扰乱字符串/solution.md
data/3.算法高阶/6.leetcode-动态规划/86.扰乱字符串/solution.md
+9
-0
data/3.算法高阶/6.leetcode-动态规划/9.正则表达式匹配/solution.md
data/3.算法高阶/6.leetcode-动态规划/9.正则表达式匹配/solution.md
+9
-0
data/3.算法高阶/6.leetcode-动态规划/90.解码方法/solution.md
data/3.算法高阶/6.leetcode-动态规划/90.解码方法/solution.md
+9
-0
data/3.算法高阶/7.leetcode-回溯算法/16.电话号码的字母组合/solution.md
data/3.算法高阶/7.leetcode-回溯算法/16.电话号码的字母组合/solution.md
+9
-0
data/3.算法高阶/7.leetcode-回溯算法/36.解数独/solution.md
data/3.算法高阶/7.leetcode-回溯算法/36.解数独/solution.md
+9
-0
data/3.算法高阶/7.leetcode-回溯算法/38.组合总和/solution.md
data/3.算法高阶/7.leetcode-回溯算法/38.组合总和/solution.md
+9
-0
data/3.算法高阶/7.leetcode-回溯算法/39.组合总和 II/solution.md
data/3.算法高阶/7.leetcode-回溯算法/39.组合总和 II/solution.md
+9
-0
data/3.算法高阶/7.leetcode-回溯算法/45.全排列/solution.md
data/3.算法高阶/7.leetcode-回溯算法/45.全排列/solution.md
+9
-0
data/3.算法高阶/7.leetcode-回溯算法/46.全排列 II/solution.md
data/3.算法高阶/7.leetcode-回溯算法/46.全排列 II/solution.md
+9
-0
data/3.算法高阶/7.leetcode-回溯算法/50.N 皇后/solution.md
data/3.算法高阶/7.leetcode-回溯算法/50.N 皇后/solution.md
+9
-0
data/3.算法高阶/7.leetcode-回溯算法/51.N皇后 II/solution.md
data/3.算法高阶/7.leetcode-回溯算法/51.N皇后 II/solution.md
+9
-0
data/3.算法高阶/7.leetcode-回溯算法/88.格雷编码/solution.md
data/3.算法高阶/7.leetcode-回溯算法/88.格雷编码/solution.md
+9
-0
data/3.算法高阶/7.leetcode-回溯算法/89.子集 II/solution.md
data/3.算法高阶/7.leetcode-回溯算法/89.子集 II/solution.md
+9
-0
data/3.算法高阶/8.leetcode-贪心/121.买卖股票的最佳时机 II/solution.md
data/3.算法高阶/8.leetcode-贪心/121.买卖股票的最佳时机 II/solution.md
+9
-0
data/3.算法高阶/8.leetcode-贪心/133.加油站/solution.md
data/3.算法高阶/8.leetcode-贪心/133.加油站/solution.md
+9
-0
data/3.算法高阶/8.leetcode-贪心/134.分发糖果/solution.md
data/3.算法高阶/8.leetcode-贪心/134.分发糖果/solution.md
+9
-0
data/3.算法高阶/8.leetcode-贪心/44.跳跃游戏 II/solution.md
data/3.算法高阶/8.leetcode-贪心/44.跳跃游戏 II/solution.md
+9
-0
data/3.算法高阶/8.leetcode-贪心/54.跳跃游戏/solution.md
data/3.算法高阶/8.leetcode-贪心/54.跳跃游戏/solution.md
+9
-0
data/3.算法高阶/8.leetcode-贪心/67.文本左右对齐/solution.md
data/3.算法高阶/8.leetcode-贪心/67.文本左右对齐/solution.md
+9
-0
未找到文件。
data/1.算法初阶/1.蓝桥杯-基础/100.第39级台阶/solution.md
浏览文件 @
ceaae444
# 第39级台阶
小明刚刚看完电影《第39级台阶》,离开电影院的时候,他数了数礼堂前的台阶数,恰好是39级!
站在台阶前,他突然又想着一个问题:
...
...
@@ -9,7 +10,9 @@
## aop
### before
```
cpp
#include <iostream>
#define LEFT 0
...
...
@@ -18,11 +21,13 @@ using namespace std;
int
stage
[
40
][
2
];
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -42,7 +47,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -62,6 +69,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -81,6 +89,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/1.蓝桥杯-基础/104.9数算式/solution.md
浏览文件 @
ceaae444
# 9数算式
观察如下的算式:
```
9213 x 85674 = 789314562
...
...
@@ -14,7 +15,9 @@
2.
乘数和被乘数交换后作为同一方案来看待。
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -22,11 +25,13 @@ int bei[10];
map
<
long
long
,
int
>
mp
;
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -80,7 +85,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -133,6 +140,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -185,6 +193,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/1.蓝桥杯-基础/106.错误票据/desc.md
浏览文件 @
ceaae444
#### 问题描述
某涉密单位下发了某种票据,并要在年终全部收回。
每张票据有唯一的ID号。全年所有票据的ID号是连续的,但ID的开始数码是随机选定的。
...
...
@@ -10,6 +11,7 @@
假设断号不可能发生在最大和最小号。
#### 输入格式
要求程序首先输入一个整数N(N<100)表示后面数据行数。
接着读入N行数据。
...
...
@@ -19,21 +21,25 @@
每个整数代表一个ID号。
#### 输出格式
要求程序输出1行,含两个整数m n,用空格分隔。
其中,m表示断号ID,n表示重号ID
#### 样例输入1
```
2
5 6 8 11 9
10 12 9
```
#### 样例输出1
```
7 9
```
#### 样例输入2
```
6
164 178 108 109 180 155 141 159 104 182 179 118 137 184 115 124 125 129 168 196
...
...
@@ -44,6 +50,7 @@
113 130 176 154 177 120 117 150 114 183 186 181 100 163 160 167 147 198 111 119
```
#### 样例输出2
```
105 120
```
\ No newline at end of file
data/1.算法初阶/1.蓝桥杯-基础/106.错误票据/solution.md
浏览文件 @
ceaae444
# 错误票据
#### 问题描述
某涉密单位下发了某种票据,并要在年终全部收回。
每张票据有唯一的ID号。全年所有票据的ID号是连续的,但ID的开始数码是随机选定的。
...
...
@@ -11,6 +13,7 @@
假设断号不可能发生在最大和最小号。
#### 输入格式
要求程序首先输入一个整数N(N<100)表示后面数据行数。
接着读入N行数据。
...
...
@@ -20,21 +23,25 @@
每个整数代表一个ID号。
#### 输出格式
要求程序输出1行,含两个整数m n,用空格分隔。
其中,m表示断号ID,n表示重号ID
#### 样例输入1
```
2
5 6 8 11 9
10 12 9
```
#### 样例输出1
```
7 9
```
#### 样例输入2
```
6
164 178 108 109 180 155 141 159 104 182 179 118 137 184 115 124 125 129 168 196
...
...
@@ -45,12 +52,15 @@
113 130 176 154 177 120 117 150 114 183 186 181 100 163 160 167 147 198 111 119
```
#### 样例输出2
```
105 120
```
## aop
### before
```
cpp
#include <iostream>
#include <stdio.h>
...
...
@@ -62,11 +72,13 @@ int ans[10005];
char
str
[
100001
];
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -103,7 +115,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -140,6 +154,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -176,6 +191,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/1.蓝桥杯-基础/112.大数乘法/solution.md
浏览文件 @
ceaae444
# 大数乘法
对于32位字长的机器,大约超过20亿,用int类型就无法表示了,我们可以选择int64类型,但无论怎样扩展,固定的整数类型总是有表达的极限!如果对超级大整数进行精确运算呢?一个简单的办法是:仅仅使用现有类型,但是把大整数的运算化解为若干小整数的运算,即所谓:“分块法”。

...
...
@@ -6,11 +7,14 @@
## aop
### before
```
cpp
#include <stdio.h>
```
### after
```
cpp
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -25,6 +29,7 @@ int main(int argc, char *argv[])
```
## 答案
```
cpp
void
bigmul
(
int
x
,
int
y
,
int
r
[])
{
...
...
@@ -52,7 +57,9 @@ void bigmul(int x, int y, int r[])
```
## 选项
### A
```
cpp
void
bigmul
(
int
x
,
int
y
,
int
r
[])
{
...
...
@@ -80,6 +87,7 @@ void bigmul(int x, int y, int r[])
```
### B
```
cpp
void
bigmul
(
int
x
,
int
y
,
int
r
[])
{
...
...
@@ -107,6 +115,7 @@ void bigmul(int x, int y, int r[])
```
### C
```
cpp
void
bigmul
(
int
x
,
int
y
,
int
r
[])
{
...
...
data/1.算法初阶/1.蓝桥杯-基础/114.大衍数列/solution.md
浏览文件 @
ceaae444
# 大衍数列
中国古代文献中,曾记载过“大衍数列”, 主要用于解释中国传统文化中的太极衍生原理。
它的前几项是:
```0、2、4、8、12、18、24、32、40、50 …```
...
...
@@ -8,16 +9,20 @@
以下的代码打印出了大衍数列的前 100 项。
## aop
### before
```
cpp
#include <stdio.h>
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -34,7 +39,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -51,6 +58,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -67,6 +75,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/1.蓝桥杯-基础/120.成绩统计/desc.md
浏览文件 @
ceaae444
#### 问题描述
编写一个程序,建立了一条单向链表,每个结点包含姓名、学号、英语成绩、数学成绩和C++成绩,并通过链表操作平均最高的学生和平均分最低的学生并且输出。
#### 输入格式
输入n+1行,第一行输入一个正整数n,表示学生数量;接下来的n行每行输入5个数据,分别表示姓名、学号、英语成绩、数学成绩和C++成绩。注意成绩有可能会有小数。
#### 输出格式
输出两行,第一行输出平均成绩最高的学生姓名。第二行输出平均成绩最低的学生姓名。
#### 样例输入
```
2
yx1 1 45 67 87
yx2 2 88 90 99
```
#### 样例输出
```
yx2
yx1
...
...
data/1.算法初阶/1.蓝桥杯-基础/120.成绩统计/solution.md
浏览文件 @
ceaae444
# 成绩统计
#### 问题描述
编写一个程序,建立了一条单向链表,每个结点包含姓名、学号、英语成绩、数学成绩和C++成绩,并通过链表操作平均最高的学生和平均分最低的学生并且输出。
#### 输入格式
输入n+1行,第一行输入一个正整数n,表示学生数量;接下来的n行每行输入5个数据,分别表示姓名、学号、英语成绩、数学成绩和C++成绩。注意成绩有可能会有小数。
#### 输出格式
输出两行,第一行输出平均成绩最高的学生姓名。第二行输出平均成绩最低的学生姓名。
#### 样例输入
```
2
yx1 1 45 67 87
yx2 2 88 90 99
```
#### 样例输出
```
yx2
yx1
```
## aop
### before
```
cpp
#include <iostream>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -68,7 +78,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -107,6 +119,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -145,6 +158,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/1.蓝桥杯-基础/126.比酒量/solution.md
浏览文件 @
ceaae444
# 比酒量
有一群海盗(不多于20人),在船上比拼酒量。过程如下:打开一瓶酒,所有在场的人平分喝下,有几个人倒下了。再打开一瓶酒平分,又有倒下的,
再次重复......
...
...
@@ -17,7 +18,9 @@
## aop
### before
```
cpp
#include <cstdio>
#include <iostream>
...
...
@@ -25,6 +28,7 @@ using namespace std;
int
d
,
a1
[
4
];
```
### after
```
cpp
int
main
()
{
...
...
@@ -50,6 +54,7 @@ int main()
```
## 答案
```
cpp
int
d1
(
int
*
a1
)
{
...
...
@@ -79,7 +84,9 @@ int getS(int *a1)
```
## 选项
### A
```
cpp
int
d1
(
int
*
a1
)
{
...
...
@@ -109,6 +116,7 @@ int getS(int *a1)
```
### B
```
cpp
int
d1
(
int
*
a1
)
{
...
...
@@ -138,6 +146,7 @@ int getS(int *a1)
```
### C
```
cpp
int
d1
(
int
*
a1
)
{
...
...
data/1.算法初阶/1.蓝桥杯-基础/134.第几天/desc.md
浏览文件 @
ceaae444
...
...
@@ -2,18 +2,23 @@ y年m月d日是哪一年的第几天。
比如y年的1月1日是那一年的第一天,那么y年m月d日是哪一年的第几天。
#### 输入
```
y m d
```
#### 输出
输出一个整数
### 样例
#### 输入
```
2000 7 7
```
#### 输出
```
189
```
data/1.算法初阶/1.蓝桥杯-基础/134.第几天/solution.md
浏览文件 @
ceaae444
# 第几天
y年m月d日是哪一年的第几天。
比如y年的1月1日是那一年的第一天,那么y年m月d日是哪一年的第几天。
#### 输入
```
y m d
```
#### 输出
输出一个整数
### 样例
#### 输入
```
2000 7 7
```
#### 输出
```
189
```
## aop
### before
```
cpp
#include <iostream>
using
namespace
std
;
...
...
@@ -31,11 +39,13 @@ bool is_leap(int year)
}
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -67,7 +77,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -98,6 +110,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -128,6 +141,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/1.蓝桥杯-基础/135.斐波那契/desc.md
浏览文件 @
ceaae444
Fibonacci数列的递推公式为:Fn=Fn-1+Fn-2,其中F1=F2=1。
当n比较大时,Fn也非常大,现在我们想知道,Fn除以10007的余数是多少。
#### 输入格式
输入包含一个整数n。
输出格式
输出一行,包含一个整数,表示Fn除以10007的余数。
说明:在本题中,答案是要求Fn除以10007的余数,因此我们只要能算出这个余数即可,而不需要先计算出Fn的准确值,再将计算的结果除以10007取余数,直接计算余数往往比先算出原数再取余简单。
#### 样例输入
```
10
```
#### 样例输出
```
55
```
#### 样例输入
```
22
```
#### 样例输出
```
7704
```
#### 数据规模与约定
```
1 <= n <= 1,000,000。
```
\ No newline at end of file
data/1.算法初阶/1.蓝桥杯-基础/135.斐波那契/solution.md
浏览文件 @
ceaae444
# 斐波那契
Fibonacci数列的递推公式为:Fn=Fn-1+Fn-2,其中F1=F2=1。
当n比较大时,Fn也非常大,现在我们想知道,Fn除以10007的余数是多少。
#### 输入格式
输入包含一个整数n。
输出格式
输出一行,包含一个整数,表示Fn除以10007的余数。
说明:在本题中,答案是要求Fn除以10007的余数,因此我们只要能算出这个余数即可,而不需要先计算出Fn的准确值,再将计算的结果除以10007取余数,直接计算余数往往比先算出原数再取余简单。
#### 样例输入
```
10
```
#### 样例输出
```
55
```
#### 样例输入
```
22
```
#### 样例输出
```
7704
```
#### 数据规模与约定
```
1 <= n <= 1,000,000。
```
## aop
### before
```
cpp
#include <stdio.h>
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -60,7 +71,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -83,6 +96,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -105,6 +119,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/1.蓝桥杯-基础/149.方阵转置/desc.md
浏览文件 @
ceaae444
#### 问题描述
给定一个n×m矩阵相乘,求它的转置。其中1≤n≤20,1≤m≤20,矩阵中的每个元素都在整数类型(4字节)的表示范围内。
#### 输入格式
第一行两个整数n和m;
第二行起,每行m个整数,共n行,表示n×m的矩阵。数据之间都用一个空格分隔。
#### 输出格式
共m行,每行n个整数,数据间用一个空格分隔,表示转置后的矩阵。
#### 样例输入
```
2 4
34 76 -54 7
-4 5 23 9
```
#### 样例输出
```
34 -4
76 5
...
...
data/1.算法初阶/1.蓝桥杯-基础/149.方阵转置/solution.md
浏览文件 @
ceaae444
# 方阵转置
#### 问题描述
给定一个n×m矩阵相乘,求它的转置。其中1≤n≤20,1≤m≤20,矩阵中的每个元素都在整数类型(4字节)的表示范围内。
#### 输入格式
第一行两个整数n和m;
第二行起,每行m个整数,共n行,表示n×m的矩阵。数据之间都用一个空格分隔。
#### 输出格式
共m行,每行n个整数,数据间用一个空格分隔,表示转置后的矩阵。
#### 样例输入
```
2 4
34 76 -54 7
-4 5 23 9
```
#### 样例输出
```
34 -4
76 5
...
...
@@ -23,18 +29,22 @@
```
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -63,7 +73,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -91,6 +103,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -118,6 +131,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/1.蓝桥杯-基础/158.倍数问题/desc.md
浏览文件 @
ceaae444
#### 题目描述
众所周知,小葱同学擅长计算,尤其擅长计算一个数是否是另外一个数的倍数。但小葱只擅长两个数的情况,当有很多个数之后就会比较苦恼。现在小葱给了你 n 个数,希望你从这 n 个数中找到三个数,使得这三个数的和是 K 的倍数,且这个和最大。数据保证一定有解。
#### 输入格式
从标准输入读入数据。
第一行包括 2 个正整数 n, K。
第二行 n 个正整数,代表给定的 n 个数。
#### 输出格式
输出到标准输出。
输出一行一个整数代表所求的和。
#### 样例输入
```
4 3
1 2 3 4
```
#### 样例输出
```
9
```
#### 样例解释
```
选择2、3、4。
```
\ No newline at end of file
data/1.算法初阶/1.蓝桥杯-基础/158.倍数问题/solution.md
浏览文件 @
ceaae444
# 倍数问题
#### 题目描述
众所周知,小葱同学擅长计算,尤其擅长计算一个数是否是另外一个数的倍数。但小葱只擅长两个数的情况,当有很多个数之后就会比较苦恼。现在小葱给了你 n 个数,希望你从这 n 个数中找到三个数,使得这三个数的和是 K 的倍数,且这个和最大。数据保证一定有解。
#### 输入格式
从标准输入读入数据。
第一行包括 2 个正整数 n, K。
第二行 n 个正整数,代表给定的 n 个数。
#### 输出格式
输出到标准输出。
输出一行一个整数代表所求的和。
#### 样例输入
```
4 3
1 2 3 4
```
#### 样例输出
```
9
```
#### 样例解释
```
选择2、3、4。
```
## aop
### before
```
cpp
#include <bits/stdc++.h>
#include <string>
...
...
@@ -44,6 +53,7 @@ int b[4];
int
flag
=
0
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -59,6 +69,7 @@ int main()
```
## 答案
```
cpp
void
dfs
(
int
a
[],
int
n
,
int
s
)
{
...
...
@@ -86,7 +97,9 @@ void dfs(int a[], int n, int s)
```
## 选项
### A
```
cpp
void
dfs
(
int
a
[],
int
n
,
int
s
)
{
...
...
@@ -114,6 +127,7 @@ void dfs(int a[], int n, int s)
```
### B
```
cpp
void
dfs
(
int
a
[],
int
n
,
int
s
)
{
...
...
@@ -141,6 +155,7 @@ void dfs(int a[], int n, int s)
```
### C
```
cpp
void
dfs
(
int
a
[],
int
n
,
int
s
)
{
...
...
data/1.算法初阶/1.蓝桥杯-基础/24.乘积尾零/solution.md
浏览文件 @
ceaae444
# 乘积尾零
如下的10行数据,每行有10个整数,请你求出它们的乘积的末尾有多少个零?
```
5650 4542 3554 473 946 4114 3871 9073 90 4329
...
...
@@ -14,17 +15,21 @@
```
## aop
### before
```
cpp
#include <iostream>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -51,7 +56,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -78,6 +85,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -105,6 +113,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/1.蓝桥杯-基础/3.分数/solution.md
浏览文件 @
ceaae444
# 分数
1/1 + 1/2 + 1/4 + 1/8 + 1/16 + … 每项是前一项的一半,如果一共有20项,求这个和是多少,结果用分数表示出来。
类似:3/2
当然,这只是加了前2项而已。分子分母要求互质。
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
gcd
(
long
a
,
long
b
)
{
...
...
@@ -25,6 +29,7 @@ int main()
```
## 答案
```
cpp
long
pow_2
(
int
b
)
{
...
...
@@ -42,7 +47,9 @@ long pow_2(int b)
```
## 选项
### A
```
cpp
long
pow_2
(
int
b
)
{
...
...
@@ -60,6 +67,7 @@ long pow_2(int b)
```
### B
```
cpp
long
pow_2
(
int
b
)
{
...
...
@@ -77,6 +85,7 @@ long pow_2(int b)
```
### C
```
cpp
long
pow_2
(
int
b
)
{
...
...
data/1.算法初阶/1.蓝桥杯-基础/4.等差素数列/desc.md
浏览文件 @
ceaae444
#### 题目描述
2,3,5,7,11,13,....是素数序列。
类似:7,37,67,97,127,157 这样完全由素数组成的等差数列,叫等差素数数列。
上边的数列公差为30,长度为6。
...
...
data/1.算法初阶/1.蓝桥杯-基础/4.等差素数列/solution.md
浏览文件 @
ceaae444
# 等差素数列
#### 题目描述
2,3,5,7,11,13,....是素数序列。
类似:7,37,67,97,127,157 这样完全由素数组成的等差数列,叫等差素数数列。
上边的数列公差为30,长度为6。
...
...
@@ -13,7 +15,9 @@
## aop
### before
```
cpp
#include <cstdio>
#include <algorithm>
...
...
@@ -34,6 +38,7 @@ bool isPrimt(LL t)
}
```
### after
```
cpp
const
int
N
=
5000
;
int
main
()
...
...
@@ -63,6 +68,7 @@ int main()
```
## 答案
```
cpp
int
f
(
LL
a
[],
int
n
)
{
...
...
@@ -89,7 +95,9 @@ int f(LL a[], int n)
```
## 选项
### A
```
cpp
int
f
(
LL
a
[],
int
n
)
{
...
...
@@ -116,6 +124,7 @@ int f(LL a[], int n)
```
### B
```
cpp
int
f
(
LL
a
[],
int
n
)
{
...
...
@@ -142,6 +151,7 @@ int f(LL a[], int n)
```
### C
```
cpp
int
f
(
LL
a
[],
int
n
)
{
...
...
data/1.算法初阶/1.蓝桥杯-基础/40.成绩分析/desc.md
浏览文件 @
ceaae444
#### 问题描述
小蓝给学生们组织了一场考试,卷面总分为100分,每个学生的得分都是一个0到100的整数。
请计算这次考试的最高分、最低分和平均分。
#### 输入格式
输入的第一行包含一个整数n,表示考试人数。
接下来n行,每行包含一个0至100的整数,表示一个学生的得分。
#### 输出格式
输出三行。
第一行包含一个整数,表示最高分。
...
...
@@ -19,6 +22,7 @@
#### 样例输入
```
7
80
...
...
@@ -30,6 +34,7 @@
10
```
#### 样例输出
```
99
10
...
...
data/1.算法初阶/1.蓝桥杯-基础/40.成绩分析/solution.md
浏览文件 @
ceaae444
# 成绩分析
#### 问题描述
小蓝给学生们组织了一场考试,卷面总分为100分,每个学生的得分都是一个0到100的整数。
请计算这次考试的最高分、最低分和平均分。
#### 输入格式
输入的第一行包含一个整数n,表示考试人数。
接下来n行,每行包含一个0至100的整数,表示一个学生的得分。
#### 输出格式
输出三行。
第一行包含一个整数,表示最高分。
...
...
@@ -20,6 +24,7 @@
#### 样例输入
```
7
80
...
...
@@ -31,6 +36,7 @@
10
```
#### 样例输出
```
99
10
...
...
@@ -38,7 +44,9 @@
```
## aop
### before
```
cpp
#include <stdio.h>
#include <iostream>
...
...
@@ -46,11 +54,13 @@
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -77,7 +87,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -103,6 +115,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -128,6 +141,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/1.蓝桥杯-基础/41.乘积最大/desc.md
浏览文件 @
ceaae444
...
...
@@ -6,19 +6,23 @@
注意,如果 X<0, 我们定义 X 除以 1000000009 的余数是负(−X)除以 1000000009 的余数,即:0−((0−x)%1000000009)
#### 输入格式
第一行包含两个整数 N 和 K。
以下 N 行每行一个整数 Ai。
#### 输出格式
输出一个整数,表示答案。
#### 数据范围
```
1≤K≤N≤105,
−105≤Ai≤105
```
#### 输入样例1:
```
5 3
-100000
...
...
@@ -28,10 +32,12 @@
10000
```
#### 输出样例1:
```
999100009
```
#### 输入样例2:
```
5 3
-100000
...
...
@@ -40,5 +46,6 @@
-100000
-100000
#### 输出样例2:
-999999829
```
\ No newline at end of file
data/1.算法初阶/1.蓝桥杯-基础/41.乘积最大/solution.md
浏览文件 @
ceaae444
# 乘积最大
给定 N 个整数 A1,A2,…AN。
请你从中选出 K 个数,使其乘积最大。
...
...
@@ -7,19 +8,23 @@
注意,如果 X<0, 我们定义 X 除以 1000000009 的余数是负(−X)除以 1000000009 的余数,即:0−((0−x)%1000000009)
#### 输入格式
第一行包含两个整数 N 和 K。
以下 N 行每行一个整数 Ai。
#### 输出格式
输出一个整数,表示答案。
#### 数据范围
```
1≤K≤N≤105,
−105≤Ai≤105
```
#### 输入样例1:
```
5 3
-100000
...
...
@@ -29,10 +34,12 @@
10000
```
#### 输出样例1:
```
999100009
```
#### 输入样例2:
```
5 3
-100000
...
...
@@ -41,11 +48,14 @@
-100000
-100000
#### 输出样例2:
-999999829
```
## aop
### before
```
cpp
#include <iostream>
#include <vector>
...
...
@@ -53,11 +63,13 @@
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -102,7 +114,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -146,6 +160,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -189,6 +204,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/1.蓝桥杯-基础/67.猜年龄/solution.md
浏览文件 @
ceaae444
# 猜年龄
美国数学家维纳(N.Wiener)智力早熟,11岁就上了大学。他曾在1935~1936年应邀来中国清华大学讲学。
一次,他参加某个重要会议,年轻的脸孔引人注目。于是有人询问他的年龄,他回答说:“我年龄的立方是个4位数。我年龄的4次方是个6位数。这10个数字正好包含了从0到9这10个数字,每个都恰好出现1次。”
请你推算一下,他当时到底有多年轻。
## aop
### before
```
cpp
```
### after
```
cpp
#include <iostream>
using
namespace
std
;
...
...
@@ -27,22 +31,27 @@ int main()
```
## 答案
```
cpp
18
```
## 选项
### A
```
cpp
19
```
### B
```
cpp
20
```
### C
```
cpp
21
```
data/1.算法初阶/1.蓝桥杯-基础/69.递增三元组/desc.md
浏览文件 @
ceaae444
...
...
@@ -7,6 +7,7 @@ C = [C1, C2, ... CN],
2.
Ai < Bj < Ck
#### 输入格式
第一行包含一个整数N。
第二行包含N个整数A1, A2, ... AN。
第三行包含N个整数B1, B2, ... BN。
...
...
@@ -17,8 +18,10 @@ C = [C1, C2, ... CN],
对于100%的数据,1 <= N <= 100000 0 <= Ai, Bi, Ci <= 100000
#### 输出格式
一个整数表示答案
#### 样例输入
```
3
1 1 1
...
...
@@ -26,6 +29,7 @@ C = [C1, C2, ... CN],
3 3 3
```
#### 样例输出
```
27
```
data/1.算法初阶/1.蓝桥杯-基础/69.递增三元组/solution.md
浏览文件 @
ceaae444
# 递增三元组
给定三个整数数组
A = [A1, A2, ... AN],
B = [B1, B2, ... BN],
...
...
@@ -8,6 +9,7 @@ C = [C1, C2, ... CN],
2.
Ai < Bj < Ck
#### 输入格式
第一行包含一个整数N。
第二行包含N个整数A1, A2, ... AN。
第三行包含N个整数B1, B2, ... BN。
...
...
@@ -18,8 +20,10 @@ C = [C1, C2, ... CN],
对于100%的数据,1 <= N <= 100000 0 <= Ai, Bi, Ci <= 100000
#### 输出格式
一个整数表示答案
#### 样例输入
```
3
1 1 1
...
...
@@ -27,13 +31,16 @@ C = [C1, C2, ... CN],
3 3 3
```
#### 样例输出
```
27
```
## aop
### before
```
cpp
#include <iostream>
#include <cstring>
...
...
@@ -47,11 +54,13 @@ int a[N], b[N], c[N], sa[N], sc[N], s[N];
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -88,7 +97,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -125,6 +136,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -161,6 +173,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/1.蓝桥杯-基础/77.第几个幸运数/solution.md
浏览文件 @
ceaae444
# 第几个幸运数
到x星球旅行的游客都被发给一个整数,作为游客编号。
x星的国王有个怪癖,他只喜欢数字3,5和7。
国王规定,游客的编号如果只含有因子:3,5,7,就可以获得一份奖品。
...
...
@@ -14,7 +15,9 @@ x星的国王有个怪癖,他只喜欢数字3,5和7。
## aop
### before
```
cpp
#include <iostream>
#include <cmath>
...
...
@@ -23,11 +26,13 @@ x星的国王有个怪癖,他只喜欢数字3,5和7。
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -62,7 +67,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -97,6 +104,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -132,6 +140,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/1.蓝桥杯-基础/88.次数差/desc.md
浏览文件 @
ceaae444
#### 问题描述
x星球有26只球队,分别用 a ~ z 的26个字母代表。他们总是不停地比赛。
在某一赛段,哪个球队获胜了,就记录下代表它的字母,这样就形成一个长长的串。
国王总是询问:获胜次数最多的和获胜次数最少的有多大差距?
(当然,他不关心那些一次也没获胜的,认为他们在怠工罢了)
#### 输入格式
一个串,表示球队获胜情况(保证串的长度<1000)
#### 输出格式
要求输出一个数字,表示出现次数最多的字母比出现次数最少的字母多了多少次。
#### 样例输入1
```
abaabcaa
```
#### 样例输出1
```
4
```
#### 提示
```
a 出现 5 次,最多;c 出现1次,最少。
5 - 1 = 4
```
#### 样例输入2
```
bbccccddaaaacccc
```
#### 样例输出2
```
6
```
\ No newline at end of file
data/1.算法初阶/1.蓝桥杯-基础/88.次数差/solution.md
浏览文件 @
ceaae444
# 次数差
#### 问题描述
x星球有26只球队,分别用 a ~ z 的26个字母代表。他们总是不停地比赛。
在某一赛段,哪个球队获胜了,就记录下代表它的字母,这样就形成一个长长的串。
国王总是询问:获胜次数最多的和获胜次数最少的有多大差距?
(当然,他不关心那些一次也没获胜的,认为他们在怠工罢了)
#### 输入格式
一个串,表示球队获胜情况(保证串的长度<1000)
#### 输出格式
要求输出一个数字,表示出现次数最多的字母比出现次数最少的字母多了多少次。
#### 样例输入1
```
abaabcaa
```
#### 样例输出1
```
4
```
#### 提示
```
a 出现 5 次,最多;c 出现1次,最少。
5 - 1 = 4
```
#### 样例输入2
```
bbccccddaaaacccc
```
#### 样例输出2
```
6
```
## aop
### before
```
cpp
#include <stdio.h>
#include <string.h>
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -75,7 +88,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -105,6 +120,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -134,6 +150,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/1.蓝桥杯-基础/99.猜字母/solution.md
浏览文件 @
ceaae444
# 猜字母
把abcd...s共19个字母组成的序列重复拼接106次,得到长度为2014的串。
接下来删除第1个字母(即开头的字母a),以及第3个,第5个等所有奇数位置的字母。
得到的新串再进行删除奇数位置字母的动作。如此下去,最后只剩下一个字母,请写出该字母。
## aop
### before
```
cpp
#include <iostream>
#include <vector>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -38,7 +43,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -61,6 +68,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -83,6 +91,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/2.蓝桥杯-字符串/92.单词分析/desc.md
浏览文件 @
ceaae444
#### 问题描述
小蓝正在学习一门神奇的语言,这门语言中的单词都是由小写英文字母组成,有些单词很长,远远超过正常英文单词的长度。小蓝学了很长时间也记不住一些单词,他准备不再完全记忆这些单词,而是根据单词中哪个字母出现得最多来分辨单词。
现在,请你帮助小蓝,给了一个单词后,帮助他找到出现最多的字母和这个字母出现的次数。
#### 输入格式
输入一行包含一个单词,单词只由小写英文字母组成。
#### 输出格式
输出两行,第一行包含一个英文字母,表示单词中出现得最多的字母是哪
个。如果有多个字母出现的次数相等,输出字典序最小的那个。
第二行包含一个整数,表示出现得最多的那个字母在单词中出现的次数。
#### 样例输入
```
lanqiao
```
#### 样例输出
```
a 2
```
#### 样例输入
```
longlonglongistoolong
```
#### 样例输出
```
o 6
```
#### 评测用例规模与约定
对于所有的评测用例,输入的单词长度不超过 1000。
data/1.算法初阶/2.蓝桥杯-字符串/92.单词分析/solution.md
浏览文件 @
ceaae444
# 单词分析
#### 问题描述
小蓝正在学习一门神奇的语言,这门语言中的单词都是由小写英文字母组成,有些单词很长,远远超过正常英文单词的长度。小蓝学了很长时间也记不住一些单词,他准备不再完全记忆这些单词,而是根据单词中哪个字母出现得最多来分辨单词。
现在,请你帮助小蓝,给了一个单词后,帮助他找到出现最多的字母和这个字母出现的次数。
#### 输入格式
输入一行包含一个单词,单词只由小写英文字母组成。
#### 输出格式
输出两行,第一行包含一个英文字母,表示单词中出现得最多的字母是哪
个。如果有多个字母出现的次数相等,输出字典序最小的那个。
第二行包含一个整数,表示出现得最多的那个字母在单词中出现的次数。
#### 样例输入
```
lanqiao
```
#### 样例输出
```
a 2
```
#### 样例输入
```
longlonglongistoolong
```
#### 样例输出
```
o 6
```
#### 评测用例规模与约定
对于所有的评测用例,输入的单词长度不超过 1000。
## aop
### before
```
cpp
#include "stdio.h"
#include "string.h"
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -73,7 +86,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -107,6 +122,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -140,6 +156,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/2.蓝桥杯-字符串/97.分类计数/desc.md
浏览文件 @
ceaae444
#### 问题描述
输入一个字符串,请输出这个字符串包含多少个大写字母,多少个小写字母,多少个数字。
#### 输入格式
输入一行包含一个字符串。
#### 输出格式
输出三行,每行一个整数,分别表示大写字母、小写字母和数字的个数。
#### 样例输入
```
1+a=Aab
```
#### 样例输出
```
1
3
1
```
#### 评测用例规模与约定
对于所有评测用例,字符串由可见字符组成,长度不超过 100。
data/1.算法初阶/2.蓝桥杯-字符串/97.分类计数/solution.md
浏览文件 @
ceaae444
# 分类计数
#### 问题描述
输入一个字符串,请输出这个字符串包含多少个大写字母,多少个小写字母,多少个数字。
#### 输入格式
输入一行包含一个字符串。
#### 输出格式
输出三行,每行一个整数,分别表示大写字母、小写字母和数字的个数。
#### 样例输入
```
1+a=Aab
```
#### 样例输出
```
1
3
1
```
#### 评测用例规模与约定
对于所有评测用例,字符串由可见字符组成,长度不超过 100。
## aop
### before
```
cpp
#include <iostream>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -66,7 +77,9 @@ int main(int argc, char **argv)
```
## 选项
### A
```
cpp
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -97,6 +110,7 @@ int main(int argc, char **argv)
```
### B
```
cpp
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -127,6 +141,7 @@ int main(int argc, char **argv)
```
### C
```
cpp
int
main
(
int
argc
,
char
**
argv
)
{
...
...
data/1.算法初阶/2.蓝桥杯-字符串/98.翻硬币/desc.md
浏览文件 @
ceaae444
#### 问题描述
小明正在玩一个“翻硬币”的游戏。
桌上放着排成一排的若干硬币。我们用
*
表示正面,用 o 表示反面(是小写字母,不是零)。
...
...
@@ -12,26 +13,32 @@
我们约定:把翻动相邻的两个硬币叫做一步操作,那么要求:
#### 输入格式
两行等长的字符串,分别表示初始状态和要达到的目标状态。每行的长度<1000
#### 输出格式
一个整数,表示最小操作步数。
#### 样例输入1
```
**********
o****o****
```
#### 样例输出1
```
5
```
#### 样例输入2
```
*o**o***o***
*o***o**o***
```
#### 样例输出2
```
1
```
\ No newline at end of file
data/1.算法初阶/2.蓝桥杯-字符串/98.翻硬币/solution.md
浏览文件 @
ceaae444
# 翻硬币
#### 问题描述
小明正在玩一个“翻硬币”的游戏。
桌上放着排成一排的若干硬币。我们用
*
表示正面,用 o 表示反面(是小写字母,不是零)。
...
...
@@ -13,42 +15,52 @@
我们约定:把翻动相邻的两个硬币叫做一步操作,那么要求:
#### 输入格式
两行等长的字符串,分别表示初始状态和要达到的目标状态。每行的长度<1000
#### 输出格式
一个整数,表示最小操作步数。
#### 样例输入1
```
**********
o****o****
```
#### 样例输出1
```
5
```
#### 样例输入2
```
*o**o***o***
*o***o**o***
```
#### 样例输出2
```
1
```
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -81,7 +93,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -114,6 +128,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -146,6 +161,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/3.蓝桥杯-递归/143.带分数/desc.md
浏览文件 @
ceaae444
#### 问题描述
100 可以表示为带分数的形式:100 = 3 + 69258 / 714。
还可以表示为:100 = 82 + 3546 / 197。
...
...
@@ -8,26 +9,32 @@
类似这样的带分数,100 有 11 种表示法。
#### 输入格式
从标准输入读入一个正整数N (N<1000
*
1000)
#### 输出格式
程序输出该数字用数码1~9不重复不遗漏地组成带分数表示的全部种数。
注意:不要求输出每个表示,只统计有多少表示法!
#### 样例输入1
```
100
```
#### 样例输出1
```
11
```
#### 样例输入2
```
105
```
#### 样例输出2
```
6
```
\ No newline at end of file
data/1.算法初阶/3.蓝桥杯-递归/143.带分数/solution.md
浏览文件 @
ceaae444
# 带分数
#### 问题描述
100 可以表示为带分数的形式:100 = 3 + 69258 / 714。
还可以表示为:100 = 82 + 3546 / 197。
...
...
@@ -9,32 +11,40 @@
类似这样的带分数,100 有 11 种表示法。
#### 输入格式
从标准输入读入一个正整数N (N<1000
*
1000)
#### 输出格式
程序输出该数字用数码1~9不重复不遗漏地组成带分数表示的全部种数。
注意:不要求输出每个表示,只统计有多少表示法!
#### 样例输入1
```
100
```
#### 样例输出1
```
11
```
#### 样例输入2
```
105
```
#### 样例输出2
```
6
```
## aop
### before
```
cpp
#include <stdio.h>
int
x
=
0
,
number
=
0
,
count
=
0
;
...
...
@@ -56,6 +66,7 @@ int getNum(int list[], int f, int r)
```
### after
```
cpp
int
main
()
{
...
...
@@ -75,6 +86,7 @@ int main()
```
## 答案
```
cpp
void
Prim
(
int
list
[],
int
k
,
int
m
)
{
...
...
@@ -116,7 +128,9 @@ void Prim(int list[], int k, int m)
```
## 选项
### A
```
cpp
void
Prim
(
int
list
[],
int
k
,
int
m
)
{
...
...
@@ -158,6 +172,7 @@ void Prim(int list[], int k, int m)
```
### B
```
cpp
void
Prim
(
int
list
[],
int
k
,
int
m
)
{
...
...
@@ -197,6 +212,7 @@ void Prim(int list[], int k, int m)
```
### C
```
cpp
void
Prim
(
int
list
[],
int
k
,
int
m
)
{
...
...
data/1.算法初阶/3.蓝桥杯-递归/163.等差数列/desc.md
浏览文件 @
ceaae444
#### 题目描述
数学老师给小明出了一道等差数列求和的题目。
但是粗心的小明忘记了一部分的数列,只记得其中 N 个整数。
...
...
@@ -6,15 +7,18 @@
现在给出这 N 个整数,小明想知道包含这 N 个整数的最短的等差数列有几项?
#### 输入格式
输入的第一行包含一个整数 N。
第二行包含 N 个整数 A1,A2,⋅⋅⋅,AN。(注意 A1∼AN 并不一定是按等差数
列中的顺序给出)
#### 输出格式
输出一个整数表示答案。
#### 数据范围
```
2≤N≤100000,
0≤Ai≤109
...
...
@@ -22,6 +26,7 @@
2
```
#### 输入样例:
```
5
2 6 4 10 20
...
...
@@ -29,9 +34,11 @@
2
```
#### 输出样例:
```
10
1
```
#### 样例解释
包含 2、6、4、10、20 的最短的等差数列是 2、4、6、8、10、12、14、16、18、20。
data/1.算法初阶/3.蓝桥杯-递归/163.等差数列/solution.md
浏览文件 @
ceaae444
# 等差数列
#### 题目描述
数学老师给小明出了一道等差数列求和的题目。
但是粗心的小明忘记了一部分的数列,只记得其中 N 个整数。
...
...
@@ -7,29 +9,36 @@
现在给出这 N 个整数,小明想知道包含这 N 个整数的最短的等差数列有几项?
#### 输入格式
输入的第一行包含一个整数 N。
第二行包含 N 个整数 A1,A2,⋅⋅⋅,AN。(注意 A1∼AN 并不一定是按等差数
列中的顺序给出)
#### 输出格式
输出一个整数表示答案。
#### 输入样例:
```
5
2 6 4 10 20
```
#### 输出样例:
```
10
```
#### 样例解释
包含 2、6、4、10、20 的最短的等差数列是 2、4、6、8、10、12、14、16、18、20。
## aop
### before
```
cpp
#include <iostream>
#include <algorithm>
...
...
@@ -44,11 +53,13 @@ int gcd(int a, int b)
}
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -74,7 +85,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -99,6 +112,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -123,6 +137,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/3.蓝桥杯-递归/35.抽签/desc.md
浏览文件 @
ceaae444
...
...
@@ -8,15 +8,19 @@ C国最多可以派出2人。
那么最终派往W星的观察团会有多少种国别的不同组合呢?
#### 输入格式
第一行N,以下N行代表N个国家最多可派出人数Ai。
#### 输出格式
最多多少种派法ANS,ANS为一个整数。
#### 输出规模
```
1<N<10000
1<AI<10000
```
#### 示例输入
```
6
4
...
...
data/1.算法初阶/3.蓝桥杯-递归/35.抽签/solution.md
浏览文件 @
ceaae444
# 抽签
X星球要派出一个5人组成的观察团前往W星。
其中:
A国最多可以派出4人。
...
...
@@ -9,15 +10,19 @@ C国最多可以派出2人。
那么最终派往W星的观察团会有多少种国别的不同组合呢?
#### 输入格式
第一行N,以下N行代表N个国家最多可派出人数Ai。
#### 输出格式
最多多少种派法ANS,ANS为一个整数。
#### 输出规模
```
1<N<10000
1<AI<10000
```
#### 示例输入
```
6
4
...
...
@@ -34,13 +39,16 @@ C国最多可以派出2人。
## aop
### before
```
cpp
#include <iostream>
using
namespace
std
;
int
a
[
10000
],
N
,
i
,
ans
=
0
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -58,6 +66,7 @@ int main()
```
## 答案
```
cpp
void
findAns
(
int
a
[],
int
start
,
int
An
)
{
...
...
@@ -76,7 +85,9 @@ void findAns(int a[], int start, int An)
```
## 选项
### A
```
cpp
void
findAns
(
int
a
[],
int
start
,
int
An
)
{
...
...
@@ -95,6 +106,7 @@ void findAns(int a[], int start, int An)
```
### B
```
cpp
void
findAns
(
int
a
[],
int
start
,
int
An
)
{
...
...
@@ -113,6 +125,7 @@ void findAns(int a[], int start, int An)
```
### C
```
cpp
void
findAns
(
int
a
[],
int
start
,
int
An
)
{
...
...
data/1.算法初阶/3.蓝桥杯-递归/58.打印图形/solution.md
浏览文件 @
ceaae444
# 打印图形
小明在X星球的城堡中发现了如下图形和文字:
```
rank=3
...
...
@@ -61,13 +62,16 @@ ran=6
## aop
### before
```
cpp
#include <cstdio>
#define N 70
```
### after
```
cpp
int
main
()
{
...
...
@@ -92,6 +96,7 @@ int main()
```
## 答案
```
cpp
void
f
(
char
a
[][
N
],
int
rank
,
int
row
,
int
col
)
{
...
...
@@ -112,7 +117,9 @@ void f(char a[][N], int rank, int row, int col)
```
## 选项
### A
```
cpp
void
f
(
char
a
[][
N
],
int
rank
,
int
row
,
int
col
)
{
...
...
@@ -133,6 +140,7 @@ void f(char a[][N], int rank, int row, int col)
```
### B
```
cpp
void
f
(
char
a
[][
N
],
int
rank
,
int
row
,
int
col
)
{
...
...
@@ -153,6 +161,7 @@ void f(char a[][N], int rank, int row, int col)
```
### C
```
cpp
void
f
(
char
a
[][
N
],
int
rank
,
int
row
,
int
col
)
{
...
...
data/1.算法初阶/4.蓝桥杯-堆栈队列链表/124.堆的计数/desc.md
浏览文件 @
ceaae444
#### 题目描述
我们知道包含N个元素的堆可以看成是一棵包含N个节点的完全二叉树。
每个节点有一个权值。对于小根堆来说,父节点的权值一定小于其子节点的权值。
...
...
@@ -29,24 +30,29 @@
#### 输入格式
一个整数N。
对于40%的数据,1 <= N <= 1000
对于70%的数据,1 <= N <= 10000
对于100%的数据,1 <= N <= 100000
#### 输出格式
一个整数表示答案。
#### 输入样例
```
4
```
#### 输出样例
```
3
```
#### 资源约定:
峰值内存消耗(含虚拟机) < 256M
CPU消耗 < 1000ms
data/1.算法初阶/4.蓝桥杯-堆栈队列链表/124.堆的计数/solution.md
浏览文件 @
ceaae444
# 堆的计数
#### 题目描述
我们知道包含N个元素的堆可以看成是一棵包含N个节点的完全二叉树。
每个节点有一个权值。对于小根堆来说,父节点的权值一定小于其子节点的权值。
...
...
@@ -30,31 +32,38 @@
#### 输入格式
一个整数N。
对于40%的数据,1 <= N <= 1000
对于70%的数据,1 <= N <= 10000
对于100%的数据,1 <= N <= 100000
#### 输出格式
一个整数表示答案。
#### 输入样例
```
4
```
#### 输出样例
```
3
```
#### 资源约定:
峰值内存消耗(含虚拟机) < 256M
CPU消耗 < 1000ms
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -83,11 +92,13 @@ ll C(ll n, ll m)
}
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -119,7 +130,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -151,6 +164,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -182,6 +196,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/6.蓝桥杯-模拟/137.夺冠概率/solution.md
浏览文件 @
ceaae444
# 夺冠概率
足球比赛具有一定程度的偶然性,弱队也有战胜强队的可能。
假设有甲、乙、丙、丁四个球队。根据他们过去比赛的成绩,得出每个队与另一个队对阵时取胜的概率表:
...
...
@@ -20,7 +21,9 @@
## aop
### before
```
cpp
#include <iostream>
using
namespace
std
;
...
...
@@ -31,11 +34,13 @@ double rate[4][4] = {
{
0.5
,
0.6
,
0.8
,
0
}};
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -63,7 +68,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -91,6 +98,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -118,6 +126,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/6.蓝桥杯-模拟/14.方程整数解/desc.md
浏览文件 @
ceaae444
#### 题目描述
方程: a^2 + b^2 + c^2 = 1000
这个方程有正整数解吗?有:a,b,c=6,8,30 就是一组解。
求出 a^2 + b^2 + c^2 = n(1
<
=
n
<=10000)
的所有解
,
解要保证c
>
=b>=a>=1。
#### 输入
存在多组测试数据,每组测试数据一行包含一个正整数n(1<=n<=10000)
#### 输出
如果无解则输出"No Solution"。
如果存在多解,每组解输出1行,输出格式:a b c,以一个空格分隔
按照a从小到大的顺序输出,如果a相同则按照b从小到大的顺序输出,如果a,b都相同则按照c从小到大的顺序输出。
#### 样例输入
```
4
1000
```
#### 样例输出
```
No Solution
6 8 30
...
...
data/1.算法初阶/6.蓝桥杯-模拟/14.方程整数解/solution.md
浏览文件 @
ceaae444
# 方程整数解
#### 题目描述
方程: a^2 + b^2 + c^2 = 1000
这个方程有正整数解吗?有:a,b,c=6,8,30 就是一组解。
求出 a^2 + b^2 + c^2 = n(1
<
=
n
<=10000)
的所有解
,
解要保证c
>
=b>=a>=1。
#### 输入
存在多组测试数据,每组测试数据一行包含一个正整数n(1<=n<=10000)
#### 输出
如果无解则输出"No Solution"。
如果存在多解,每组解输出1行,输出格式:a b c,以一个空格分隔
按照a从小到大的顺序输出,如果a相同则按照b从小到大的顺序输出,如果a,b都相同则按照c从小到大的顺序输出。
#### 样例输入
```
4
1000
```
#### 样例输出
```
No Solution
6 8 30
...
...
@@ -23,18 +29,22 @@ No Solution
```
## aop
### before
```
cpp
#include <iostream>
#include <cmath>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -69,7 +79,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -103,6 +115,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -136,6 +149,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/6.蓝桥杯-模拟/162.7段码/desc.md
浏览文件 @
ceaae444
#### 题目描述
小蓝要用七段码数码管来表示一种特殊的文字。

...
...
data/1.算法初阶/6.蓝桥杯-模拟/162.7段码/solution.md
浏览文件 @
ceaae444
# 7段码
#### 题目描述
小蓝要用七段码数码管来表示一种特殊的文字。

上图给出了七段码数码管的一个图示,数码管中一共有 7 段可以发光的二极管,分别标记为 a, b, c, d, e, f, g。
...
...
@@ -19,7 +21,9 @@
请问,小蓝可以用七段码数码管表达多少种不同的字符?
## aop
### before
```
cpp
#include <iostream>
using
namespace
std
;
...
...
@@ -45,6 +49,7 @@ int find(int a)
}
```
### after
```
cpp
int
main
()
{
...
...
@@ -57,6 +62,7 @@ int main()
```
## 答案
```
cpp
void
dfs
(
int
d
)
{
...
...
@@ -105,7 +111,9 @@ void dfs(int d)
```
## 选项
### A
```
cpp
void
dfs
(
int
d
)
{
...
...
@@ -154,6 +162,7 @@ void dfs(int d)
```
### B
```
cpp
void
dfs
(
int
d
)
{
...
...
@@ -202,6 +211,7 @@ void dfs(int d)
```
### C
```
cpp
void
dfs
(
int
d
)
{
...
...
data/1.算法初阶/6.蓝桥杯-模拟/175.颠倒的价牌/solution.md
浏览文件 @
ceaae444
# 颠倒的价牌
小李的店里专卖其它店中下架的样品电视机,可称为:样品电视专卖店。
其标价都是4位数字(即千元不等)。
小李为了标价清晰、方便,使用了预制的类似数码管的标价签,只要用颜色笔涂数字就可以了(参见图片)。
...
...
@@ -12,17 +13,21 @@
## aop
### before
```
cpp
#include <iostream>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -80,7 +85,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -138,6 +145,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -195,6 +203,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/6.蓝桥杯-模拟/187.承压计算/solution.md
浏览文件 @
ceaae444
# 承压计算
X星球的高科技实验室中整齐地堆放着某批珍贵金属原料。
每块金属原料的外形、尺寸完全一致,但重量不同。
...
...
@@ -52,7 +53,9 @@ X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X
## aop
### before
```
cpp
#include <stdio.h>
#include <string.h>
...
...
@@ -65,11 +68,13 @@ double a[1050][1050];
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -100,7 +105,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
...
...
@@ -132,6 +139,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -162,6 +170,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/6.蓝桥杯-模拟/23.放棋子/solution.md
浏览文件 @
ceaae444
# 放棋子
今有6×6的棋盘,其中某些格子已预放了棋子。现在要再放上去一些,使得每行每列都正好有3颗棋子。我们希望推算出所有可能的放法,下面的代码就实现了这个功能。初始数组中,“1”表示放有棋子,“0”表示空白。

## aop
### before
```
cpp
#include <iostream>
#include <cstdio>
...
...
@@ -71,6 +74,7 @@ void GoNext(int x[][6], int r, int c)
}
```
### after
```
cpp
int
main
()
{
...
...
@@ -89,6 +93,7 @@ int main()
```
## 答案
```
cpp
void
f
(
int
x
[][
6
],
int
r
,
int
c
)
{
...
...
@@ -130,7 +135,9 @@ void f(int x[][6], int r, int c)
```
## 选项
### A
```
cpp
void
f
(
int
x
[][
6
],
int
r
,
int
c
)
{
...
...
@@ -168,6 +175,7 @@ void f(int x[][6], int r, int c)
```
### B
```
cpp
void
f
(
int
x
[][
6
],
int
r
,
int
c
)
{
...
...
@@ -206,6 +214,7 @@ void f(int x[][6], int r, int c)
```
### C
```
cpp
void
f
(
int
x
[][
6
],
int
r
,
int
c
)
{
...
...
data/1.算法初阶/6.蓝桥杯-模拟/28.分巧克力/desc.md
浏览文件 @
ceaae444
...
...
@@ -7,18 +7,22 @@
例如一块6x5的巧克力可以切出6块2x2的巧克力或者2块3x3的巧克力。
当然小朋友们都希望得到的巧克力尽可能大,你能帮小Hi计算出最大的边长是多少么?
#### 输入
第一行包含两个整数N和K。(1 <= N, K <= 100000)
以下N行每行包含两个整数Hi和Wi。(1 <= Hi, Wi <= 100000)
输入保证每位小朋友至少能获得一块1x1的巧克力。
#### 输出
输出切出的正方形巧克力最大可能的边长。
#### 样例输入:
```
2 10
6 5
5 6
```
#### 样例输出:
```
2
```
...
...
data/1.算法初阶/6.蓝桥杯-模拟/28.分巧克力/solution.md
浏览文件 @
ceaae444
# 分巧克力
儿童节那天有K位小朋友到小明家做客。小明拿出了珍藏的巧克力招待小朋友们。
小明一共有N块巧克力,其中第i块是Hi x Wi的方格组成的长方形。
为了公平起见,小明需要从这 N 块巧克力中切出K块巧克力分给小朋友们。切出的巧克力需要满足:
...
...
@@ -8,18 +9,22 @@
例如一块6x5的巧克力可以切出6块2x2的巧克力或者2块3x3的巧克力。
当然小朋友们都希望得到的巧克力尽可能大,你能帮小Hi计算出最大的边长是多少么?
#### 输入
第一行包含两个整数N和K。(1 <= N, K <= 100000)
以下N行每行包含两个整数Hi和Wi。(1 <= Hi, Wi <= 100000)
输入保证每位小朋友至少能获得一块1x1的巧克力。
#### 输出
输出切出的正方形巧克力最大可能的边长。
#### 样例输入:
```
2 10
6 5
5 6
```
#### 样例输出:
```
2
```
...
...
@@ -27,7 +32,9 @@
## aop
### before
```
cpp
#include <stdio.h>
#include <string.h>
...
...
@@ -45,6 +52,7 @@ int coun(int n, int x)
```
### after
```
cpp
int
main
()
{
...
...
@@ -58,6 +66,7 @@ int main()
```
## 答案
```
cpp
int
binary
(
int
n
,
int
k
)
{
...
...
@@ -77,7 +86,9 @@ int binary(int n, int k)
```
## 选项
### A
```
cpp
int
binary
(
int
n
,
int
k
)
{
...
...
@@ -97,6 +108,7 @@ int binary(int n, int k)
```
### B
```
cpp
int
binary
(
int
n
,
int
k
)
{
...
...
@@ -116,6 +128,7 @@ int binary(int n, int k)
```
### C
```
cpp
int
binary
(
int
n
,
int
k
)
{
...
...
data/1.算法初阶/6.蓝桥杯-模拟/53.等腰三角形/desc.md
浏览文件 @
ceaae444
...
...
@@ -10,21 +10,30 @@
为了便于测评,我们要求空格一律用"."代替。
### 例如:
#### 输入:
5
#### 程序应该输出:

### 再例如:
#### 输入:
10
#### 程序应该输出:

### 再例如:
#### 输入:
15
#### 程序应该输出:

data/1.算法初阶/6.蓝桥杯-模拟/53.等腰三角形/solution.md
浏览文件 @
ceaae444
# 等腰三角形
本题目要求你在控制台输出一个由数字组成的等腰三角形。具体的步骤是:
先用1,2,3,…的自然数拼一个足够长的串
...
...
@@ -11,28 +12,39 @@
为了便于测评,我们要求空格一律用"."代替。
### 例如:
#### 输入:
5
#### 程序应该输出:

### 再例如:
#### 输入:
10
#### 程序应该输出:

### 再例如:
#### 输入:
15
#### 程序应该输出:

## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -40,11 +52,13 @@ string str;
stringstream
ss
;
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -107,7 +121,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -170,6 +186,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -232,6 +249,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/6.蓝桥杯-模拟/54.分糖果/desc.md
浏览文件 @
ceaae444
#### 问题描述
有n个小朋友围坐成一圈。老师给每个小朋友随机发偶数个糖果,然后进行下面的游戏:
每个小朋友都把自己的糖果分一半给左手边的孩子。
一轮分糖后,拥有奇数颗糖的孩子由老师补给1个糖果,从而变成偶数。
...
...
@@ -6,18 +7,22 @@
你的任务是预测在已知的初始糖果情形下,老师一共需要补发多少个糖果。
#### 输入格式
程序首先读入一个整数N(2<N<100),表示小朋友的人数。
接着是一行用空格分开的N个偶数(每个偶数不大于1000,不小于2)
#### 输出格式
要求程序输出一个整数,表示老师需要补发的糖果数。
#### 样例输入
```
3
2 2 4
```
#### 样例输出
```
4
```
\ No newline at end of file
data/1.算法初阶/6.蓝桥杯-模拟/54.分糖果/solution.md
浏览文件 @
ceaae444
# 分糖果
#### 问题描述
有n个小朋友围坐成一圈。老师给每个小朋友随机发偶数个糖果,然后进行下面的游戏:
每个小朋友都把自己的糖果分一半给左手边的孩子。
一轮分糖后,拥有奇数颗糖的孩子由老师补给1个糖果,从而变成偶数。
...
...
@@ -7,34 +9,42 @@
你的任务是预测在已知的初始糖果情形下,老师一共需要补发多少个糖果。
#### 输入格式
程序首先读入一个整数N(2<N<100),表示小朋友的人数。
接着是一行用空格分开的N个偶数(每个偶数不大于1000,不小于2)
#### 输出格式
要求程序输出一个整数,表示老师需要补发的糖果数。
#### 样例输入
```
3
2 2 4
```
#### 样例输出
```
4
```
## aop
### before
```
cpp
#include <iostream>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -80,7 +90,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -126,6 +138,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -171,6 +184,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/6.蓝桥杯-模拟/63.方格填数/solution.md
浏览文件 @
ceaae444
# 方格填数
如下图

填入0~9的数字。要求:连续的两个数字不能相邻。
...
...
@@ -7,7 +8,9 @@
一共有多少种可能的填数方案?
## aop
### before
```
cpp
#include <iostream>
#include <algorithm>
...
...
@@ -19,6 +22,7 @@ int ans;
```
### after
```
cpp
int
main
()
{
...
...
@@ -36,6 +40,7 @@ int main()
```
## 答案
```
cpp
bool
check
()
{
...
...
@@ -60,7 +65,9 @@ bool check()
```
## 选项
### A
```
cpp
bool
check
()
{
...
...
@@ -85,6 +92,7 @@ bool check()
```
### B
```
cpp
bool
check
()
{
...
...
@@ -111,6 +119,7 @@ bool check()
```
### C
```
cpp
bool
check
()
{
...
...
data/1.算法初阶/7.蓝桥杯-搜索/121.超级胶水/solution.md
浏览文件 @
ceaae444
# 超级胶水
小明有n颗石子,按顺序摆成一排。他准备用胶水将这些石子粘在一起。每颗石子有自己的重量,如果将两颗石子粘在一起,将合并成一颗新的石子,重量是这两颗石子的重量之和。
为了保证石子粘贴牢固,粘贴两颗石子所需要的胶水与两颗石子的重量乘积成正比,本题不考虑物理单位,认为所需要的胶水在数值上等于两颗石子重量的乘积。
每次合并,小明只能合并位置相邻的两颗石子,并将合并出的新石子放在原来的位置。
...
...
@@ -19,7 +20,9 @@
## aop
### before
```
cpp
#include<bits/stdc++.h>
using
namespace
std
;
...
...
@@ -32,6 +35,7 @@ int v[maxn];
```
### after
```
cpp
int
main
(){
...
...
@@ -50,6 +54,7 @@ int main(){
```
## 答案
```
cpp
int
dfs
(
int
idx
){
...
...
@@ -69,7 +74,9 @@ int dfs(int idx){
```
## 选项
### A
```
cpp
int
dfs
(
int
idx
)
{
...
...
@@ -89,6 +96,7 @@ int dfs(int idx)
```
### B
```
cpp
int
dfs
(
int
idx
)
{
...
...
@@ -108,6 +116,7 @@ int dfs(int idx)
```
### C
```
cpp
int
dfs
(
int
idx
)
{
...
...
data/1.算法初阶/7.蓝桥杯-搜索/156.凑算式/solution.md
浏览文件 @
ceaae444
# 凑算式
```
B DEF
A + —- + ——–- = 10
...
...
@@ -14,7 +15,9 @@ A + —- + ——–- = 10
## aop
### before
```
cpp
#include <stdio.h>
#include <stdbool.h>
...
...
@@ -35,6 +38,7 @@ void judge()
}
```
### after
```
cpp
int
main
()
{
...
...
@@ -46,6 +50,7 @@ int main()
```
## 答案
```
cpp
void
dfs
(
int
index
)
{
...
...
@@ -69,7 +74,9 @@ void dfs(int index)
```
## 选项
### A
```
cpp
void
dfs
(
int
index
)
{
...
...
@@ -93,6 +100,7 @@ void dfs(int index)
```
### B
```
cpp
void
dfs
(
int
index
)
{
...
...
@@ -116,6 +124,7 @@ void dfs(int index)
```
### C
```
cpp
void
dfs
(
int
index
)
{
...
...
data/1.算法初阶/7.蓝桥杯-搜索/188.大臣的旅费/desc.md
浏览文件 @
ceaae444
#### 问题描述
很久以前,T王国空前繁荣。为了更好地管理国家,王国修建了大量的快速路,用于连接首都和王国内的各大城市。
为节省经费,T国的大臣们经过思考,制定了一套优秀的修建方案,使得任何一个大城市都能从首都直接或者通过其他大城市间接到达。同时,如果不重复经过大城市,从首都到达每个大城市的方案都是唯一的。
...
...
@@ -10,6 +11,7 @@ J是T国重要大臣,他巡查于各大城市之间,体察民情。所以,
J大臣想知道:他从某一个城市出发,中间不休息,到达另一个城市,所有可能花费的路费中最多是多少呢?
#### 输入格式
输入的第一行包含一个整数n,表示包括首都在内的T王国的城市数
城市从1开始依次编号,1号城市为首都。
...
...
@@ -19,9 +21,11 @@ J大臣想知道:他从某一个城市出发,中间不休息,到达另一
每行三个整数Pi, Qi, Di,表示城市Pi和城市Qi之间有一条高速路,长度为Di千米。
#### 输出格式
输出一个整数,表示大臣J最多花费的路费是多少。
#### 样例输入1
```
5
1 2 2
...
...
@@ -30,10 +34,12 @@ J大臣想知道:他从某一个城市出发,中间不休息,到达另一
2 5 4
```
#### 样例输出1
```
135
```
#### 输出格式
```
大臣J从城市4到城市5要花费135的路费。
```
\ No newline at end of file
data/1.算法初阶/7.蓝桥杯-搜索/188.大臣的旅费/solution.md
浏览文件 @
ceaae444
# 大臣的旅费
#### 问题描述
很久以前,T王国空前繁荣。为了更好地管理国家,王国修建了大量的快速路,用于连接首都和王国内的各大城市。
为节省经费,T国的大臣们经过思考,制定了一套优秀的修建方案,使得任何一个大城市都能从首都直接或者通过其他大城市间接到达。同时,如果不重复经过大城市,从首都到达每个大城市的方案都是唯一的。
...
...
@@ -11,6 +13,7 @@ J是T国重要大臣,他巡查于各大城市之间,体察民情。所以,
J大臣想知道:他从某一个城市出发,中间不休息,到达另一个城市,所有可能花费的路费中最多是多少呢?
#### 输入格式
输入的第一行包含一个整数n,表示包括首都在内的T王国的城市数
城市从1开始依次编号,1号城市为首都。
...
...
@@ -20,9 +23,11 @@ J大臣想知道:他从某一个城市出发,中间不休息,到达另一
每行三个整数Pi, Qi, Di,表示城市Pi和城市Qi之间有一条高速路,长度为Di千米。
#### 输出格式
输出一个整数,表示大臣J最多花费的路费是多少。
#### 样例输入1
```
5
1 2 2
...
...
@@ -31,16 +36,20 @@ J大臣想知道:他从某一个城市出发,中间不休息,到达另一
2 5 4
```
#### 样例输出1
```
135
```
#### 输出格式
```
大臣J从城市4到城市5要花费135的路费。
```
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -55,6 +64,7 @@ ll dis[maxn];
ll
sum
=
0
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -83,6 +93,7 @@ int main()
```
## 答案
```
cpp
int
bfs
(
int
node
)
{
...
...
@@ -115,7 +126,9 @@ int bfs(int node)
```
## 选项
### A
```
cpp
int
bfs
(
int
node
)
{
...
...
@@ -145,6 +158,7 @@ int bfs(int node)
```
### B
```
cpp
int
bfs
(
int
node
)
{
...
...
@@ -174,6 +188,7 @@ int bfs(int node)
```
### C
```
cpp
int
bfs
(
int
node
)
{
...
...
data/1.算法初阶/7.蓝桥杯-搜索/51.分配口罩/solution.md
浏览文件 @
ceaae444
# 分配口罩
某市市长获得了若干批口罩,给定每批口罩的数量,市长要把口罩分配给市内的2所医院。
```
...
...
@@ -12,7 +13,9 @@ masks = [9090400, 8499400, 5926800, 8547000, 4958200, 4422600, 5751200, 4175600,
## aop
### before
```
cpp
#include <iostream>
#include <algorithm>
...
...
@@ -25,6 +28,7 @@ long int masks[15] = {9090400, 8499400, 5926800, 8547000, 4958200,
long
ans
=
1000000000
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -35,6 +39,7 @@ int main()
```
## 答案
```
cpp
void
dfs
(
int
n
,
long
h1
,
long
h2
)
{
...
...
@@ -50,7 +55,9 @@ void dfs(int n, long h1, long h2)
```
## 选项
### A
```
cpp
void
dfs
(
int
n
,
long
h1
,
long
h2
)
{
...
...
@@ -65,6 +72,7 @@ void dfs(int n, long h1, long h2)
```
### B
```
cpp
void
dfs
(
int
n
,
long
h1
,
long
h2
)
{
...
...
@@ -79,6 +87,7 @@ void dfs(int n, long h1, long h2)
```
### C
```
cpp
void
dfs
(
int
n
,
long
h1
,
long
h2
)
{
...
...
data/1.算法初阶/7.蓝桥杯-搜索/6.搭积木/solution.md
浏览文件 @
ceaae444
# 搭积木
小明最近喜欢搭数字积木,
一共有10块积木,每个积木上有一个数字,0~9。
...
...
@@ -23,7 +24,9 @@
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -60,6 +63,7 @@ bool judge()
int
ans
=
0
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -71,6 +75,7 @@ int main()
```
## 答案
```
cpp
void
dfs
(
int
idx
)
{
...
...
@@ -99,7 +104,9 @@ void dfs(int idx)
```
## 选项
### A
```
cpp
void
dfs
(
int
idx
)
{
...
...
@@ -128,6 +135,7 @@ void dfs(int idx)
```
### B
```
cpp
void
dfs
(
int
idx
)
{
...
...
@@ -156,6 +164,7 @@ void dfs(int idx)
```
### C
```
cpp
void
dfs
(
int
idx
)
{
...
...
data/1.算法初阶/7.蓝桥杯-搜索/65.方格分割/solution.md
浏览文件 @
ceaae444
# 方格分割
6x6的方格,沿着格子的边线剪开成两部分。
要求这两部分的形状完全相同。
...
...
@@ -13,7 +14,9 @@
注意:旋转对称的属于同一种分割法。
## aop
### before
```
cpp
#include <iostream>
using
namespace
std
;
...
...
@@ -23,6 +26,7 @@ int dire[][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
int
vis
[
7
][
7
];
```
### after
```
cpp
int
main
()
{
...
...
@@ -33,6 +37,7 @@ int main()
```
## 答案
```
cpp
void
dfs
(
int
x
,
int
y
)
{
...
...
@@ -63,7 +68,9 @@ void dfs(int x, int y)
```
## 选项
### A
```
cpp
void
dfs
(
int
x
,
int
y
)
{
...
...
@@ -94,6 +101,7 @@ void dfs(int x, int y)
```
### B
```
cpp
void
dfs
(
int
x
,
int
y
)
{
...
...
@@ -124,6 +132,7 @@ void dfs(int x, int y)
```
### C
```
cpp
void
dfs
(
int
x
,
int
y
)
{
...
...
data/1.算法初阶/9.蓝桥杯-动态规划/117.地宫取宝/desc.md
浏览文件 @
ceaae444
...
...
@@ -6,36 +6,43 @@ X 国王有一个地宫宝库,是 n×m 个格子的矩阵,每个格子放一
请你帮小明算一算,在给定的局面下,他有多少种不同的行动方案能获得这 k 件宝贝。
#### 输入格式
第一行 3 个整数,n,m,k,含义见题目描述。
接下来 n 行,每行有 m 个整数 Ci 用来描述宝库矩阵每个格子的宝贝价值。
#### 输出格式
输出一个整数,表示正好取 k 个宝贝的行动方案数。
该数字可能很大,输出它对 1000000007 取模的结果。
#### 数据范围
```
1≤n,m≤50,
1≤k≤12,
0≤Ci≤12
```
#### 输入样例1:
```
2 2 2
1 2
2 1
```
#### 输出样例1:
```
2
```
#### 输入样例2:
```
2 3 2
1 2 3
2 1 5
```
#### 输出样例2:
```
14
```
\ No newline at end of file
data/1.算法初阶/9.蓝桥杯-动态规划/117.地宫取宝/solution.md
浏览文件 @
ceaae444
# 地宫取宝
X 国王有一个地宫宝库,是 n×m 个格子的矩阵,每个格子放一件宝贝,每个宝贝贴着价值标签。
地宫的入口在左上角,出口在右下角。
小明被带到地宫的入口,国王要求他只能向右或向下行走。
...
...
@@ -7,42 +8,51 @@ X 国王有一个地宫宝库,是 n×m 个格子的矩阵,每个格子放一
请你帮小明算一算,在给定的局面下,他有多少种不同的行动方案能获得这 k 件宝贝。
#### 输入格式
第一行 3 个整数,n,m,k,含义见题目描述。
接下来 n 行,每行有 m 个整数 Ci 用来描述宝库矩阵每个格子的宝贝价值。
#### 输出格式
输出一个整数,表示正好取 k 个宝贝的行动方案数。
该数字可能很大,输出它对 1000000007 取模的结果。
#### 数据范围
```
1≤n,m≤50,
1≤k≤12,
0≤Ci≤12
```
#### 输入样例1:
```
2 2 2
1 2
2 1
```
#### 输出样例1:
```
2
```
#### 输入样例2:
```
2 3 2
1 2 3
2 1 5
```
#### 输出样例2:
```
14
```
## aop
### before
```
cpp
#include <iostream>
using
namespace
std
;
...
...
@@ -53,11 +63,13 @@ int g[N][N];
int
n
,
m
,
k
;
```
### after
```
cpp
```
## 答案
```
cpp
int
main
()
{
...
...
@@ -104,7 +116,9 @@ int main()
```
## 选项
### A
```
cpp
int
main
()
{
...
...
@@ -150,6 +164,7 @@ int main()
```
### B
```
cpp
int
main
()
{
...
...
@@ -195,6 +210,7 @@ int main()
```
### C
```
cpp
int
main
()
{
...
...
data/1.算法初阶/9.蓝桥杯-动态规划/91.测试次数/solution.md
浏览文件 @
ceaae444
# 测试次数
x星球的居民脾气不太好,但好在他们生气的时候唯一的异常举动是:摔手机。
各大厂商也就纷纷推出各种耐摔型手机。x星球的质监局规定了手机必须经过耐摔测试,并且评定出一个耐摔指数来,之后才允许上市流通。
...
...
@@ -14,13 +15,16 @@ x星球有很多高耸入云的高塔,刚好可以用来做耐摔测试。塔
## aop
### before
```
cpp
#include <iostream>
using
namespace
std
;
int
num
[
5
][
1010
]
=
{
0
};
```
### after
```
cpp
int
main
()
{
...
...
@@ -30,6 +34,7 @@ int main()
```
## 答案
```
cpp
int
dp
(
int
k
,
int
n
)
{
...
...
@@ -50,7 +55,9 @@ int dp(int k, int n)
```
## 选项
### A
```
cpp
int
dp
(
int
k
,
int
n
)
{
...
...
@@ -71,6 +78,7 @@ int dp(int k, int n)
```
### B
```
cpp
int
dp
(
int
k
,
int
n
)
{
...
...
@@ -91,6 +99,7 @@ int dp(int k, int n)
```
### C
```
cpp
int
dp
(
int
k
,
int
n
)
{
...
...
data/2.算法中阶/1.leetcode-数组/0.两数之和/solution.md
浏览文件 @
ceaae444
# 两数之和
<p>
给定一个整数数组
<code>
nums
</code>
和一个整数目标值
<code>
target
</code>
,请你在该数组中找出
<strong>
和为目标值
</strong>
的那
<strong>
两个
</strong>
整数,并返回它们的数组下标。
</p><p>
你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。
</p><p>
你可以按任意顺序返回答案。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
nums = [2,7,11,15], target = 9
<strong><br
/>
输出:
</strong>
[0,1]
<strong><br
/>
解释:
</strong>
因为 nums[0] + nums[1] == 9 ,返回 [0, 1] 。
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
nums = [3,2,4], target = 6
<strong><br
/>
输出:
</strong>
[1,2]
</pre><p><strong>
示例 3:
</strong></p><pre><strong>
输入:
</strong>
nums = [3,3], target = 6
<strong><br
/>
输出:
</strong>
[0,1]
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
2
<
=
nums.length
<=
10<
sup
>
3
</sup></code></li>
<li><code>
-10
<sup>
9
</sup>
<
=
nums
[
i
]
<=
10<
sup
>
9
</sup></code></li>
<li><code>
-10
<sup>
9
</sup>
<
=
target
<=
10<
sup
>
9
</sup></code></li>
<li><strong>
只会存在一个有效答案
</strong></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <unordered_map>
#include <vector>
...
...
@@ -12,6 +15,7 @@
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -29,6 +33,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -56,7 +61,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -84,6 +91,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -111,6 +119,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/1.leetcode-数组/14.三数之和/solution.md
浏览文件 @
ceaae444
# 三数之和
<p>
给你一个包含
<code>
n
</code>
个整数的数组
<code>
nums
</code>
,判断
<code>
nums
</code>
中是否存在三个元素
<em>
a,b,c ,
</em>
使得
<em>
a + b + c =
</em>
0 ?请你找出所有和为
<code>
0
</code>
且不重复的三元组。
</p><p><strong>
注意:
</strong>
答案中不可以包含重复的三元组。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
nums = [-1,0,1,2,-1,-4]
<strong><br
/>
输出:
</strong>
[[-1,-1,2],[-1,0,1]]
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
nums = []
<strong><br
/>
输出:
</strong>
[]
</pre><p><strong>
示例 3:
</strong></p><pre><strong>
输入:
</strong>
nums = [0]
<strong><br
/>
输出:
</strong>
[]
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
0
<
=
nums.length
<=
3000</
code
></li>
<li><code>
-10
<sup>
5
</sup>
<
=
nums
[
i
]
<=
10<
sup
>
5
</sup></code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <vector>
#include <iostream>
...
...
@@ -12,6 +15,7 @@
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -34,6 +38,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -72,7 +77,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -125,6 +132,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -166,6 +174,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/1.leetcode-数组/17.四数之和/solution.md
浏览文件 @
ceaae444
# 四数之和
<p>
给定一个包含
<em>
n
</em>
个整数的数组
<code>
nums
</code>
和一个目标值
<code>
target
</code>
,判断
<code>
nums
</code>
中是否存在四个元素
<em>
a,
</em><em>
b,c
</em>
和
<em>
d
</em>
,使得
<em>
a
</em>
+
<em>
b
</em>
+
<em>
c
</em>
+
<em>
d
</em>
的值与
<code>
target
</code>
相等?找出所有满足条件且不重复的四元组。
</p><p><strong>
注意:
</strong>
答案中不可以包含重复的四元组。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
nums = [1,0,-1,0,-2,2], target = 0
<strong><br
/>
输出:
</strong>
[[-2,-1,1,2],[-2,0,0,2],[-1,0,0,1]]
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
nums = [], target = 0
<strong><br
/>
输出:
</strong>
[]
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
0
<
=
nums.length
<=
200</
code
></li>
<li><code>
-10
<sup>
9
</sup>
<
=
nums
[
i
]
<=
10<
sup
>
9
</sup></code></li>
<li><code>
-10
<sup>
9
</sup>
<
=
target
<=
10<
sup
>
9
</sup></code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -34,6 +38,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -82,7 +87,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -140,6 +147,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -185,6 +193,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/1.leetcode-数组/3.寻找两个正序数组的中位数/solution.md
浏览文件 @
ceaae444
# 寻找两个正序数组的中位数
<p>
给定两个大小分别为
<code>
m
</code>
和
<code>
n
</code>
的正序(从小到大)数组
<code>
nums1
</code>
和
<code>
nums2
</code>
。请你找出并返回这两个正序数组的
<strong>
中位数
</strong>
。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
nums1 = [1,3], nums2 = [2]
<strong><br
/>
输出:
</strong>
2.00000
<strong><br
/>
解释:
</strong>
合并数组 = [1,2,3] ,中位数 2
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
nums1 = [1,2], nums2 = [3,4]
<strong><br
/>
输出:
</strong>
2.50000
<strong><br
/>
解释:
</strong>
合并数组 = [1,2,3,4] ,中位数 (2 + 3) / 2 = 2.5
</pre><p><strong>
示例 3:
</strong></p><pre><strong>
输入:
</strong>
nums1 = [0,0], nums2 = [0,0]
<strong><br
/>
输出:
</strong>
0.00000
</pre><p><strong>
示例 4:
</strong></p><pre><strong>
输入:
</strong>
nums1 = [], nums2 = [1]
<strong><br
/>
输出:
</strong>
1.00000
</pre><p><strong>
示例 5:
</strong></p><pre><strong>
输入:
</strong>
nums1 = [2], nums2 = []
<strong><br
/>
输出:
</strong>
2.00000
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
nums1.length == m
</code></li>
<li><code>
nums2.length == n
</code></li>
<li><code>
0
<
=
m
<=
1000</
code
></li>
<li><code>
0
<
=
n
<=
1000</
code
></li>
<li><code>
1
<
=
m
+
n
<=
2000</
code
></li>
<li><code>
-10
<sup>
6
</sup>
<
=
nums1
[
i
],
nums2
[
i
]
<=
10<
sup
>
6
</sup></code></li></ul><p>
</p><p><strong>
进阶:
</strong>
你能设计一个时间复杂度为
<code>
O(log (m+n))
</code>
的算法解决此问题吗?
</p>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -30,6 +34,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -87,7 +92,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -124,6 +131,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -143,6 +151,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/1.leetcode-数组/32.搜索旋转排序数组/solution.md
浏览文件 @
ceaae444
# 搜索旋转排序数组
<p>
整数数组
<code>
nums
</code>
按升序排列,数组中的值
<strong>
互不相同
</strong>
。
</p>
<p>
在传递给函数之前,
<code>
nums
</code>
在预先未知的某个下标
<code>
k
</code>
(
<code>
0
<
=
k
<
nums.length
</
code
>
)上进行了
<strong>
旋转
</strong>
,使数组变为
<code>
[nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]]
</code>
(下标
<strong>
从 0 开始
</strong>
...
...
@@ -28,12 +29,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -50,6 +54,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -84,7 +89,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -129,6 +136,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -155,6 +163,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/1.leetcode-数组/33.在排序数组中查找元素的第一个和最后一个位置/solution.md
浏览文件 @
ceaae444
# 在排序数组中查找元素的第一个和最后一个位置
<p>
给定一个按照升序排列的整数数组
<code>
nums
</code>
,和一个目标值
<code>
target
</code>
。找出给定目标值在数组中的开始位置和结束位置。
</p>
<p>
如果数组中不存在目标值
<code>
target
</code>
,返回
<code>
[-1, -1]
</code>
。
</p>
<p><strong>
进阶:
</strong></p>
...
...
@@ -23,12 +24,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -46,6 +50,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -114,7 +119,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -170,6 +177,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -237,6 +245,7 @@ private:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/1.leetcode-数组/34.搜索插入位置/solution.md
浏览文件 @
ceaae444
# 搜索插入位置
<p>
给定一个排序数组和一个目标值,在数组中找到目标值,并返回其索引。如果目标值不存在于数组中,返回它将会被按顺序插入的位置。
</p><p>
你可以假设数组中无重复元素。
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
[1,3,5,6], 5
<strong><br
/>
输出:
</strong>
2
</pre><p><strong>
示例
2:
</strong></p><pre><strong>
输入:
</strong>
[1,3,5,6], 2
<strong><br
/>
输出:
</strong>
1
</pre><p><strong>
示例 3:
</strong></p><pre><strong>
输入:
</strong>
[1,3,5,6], 7
<strong><br
/>
输出:
</strong>
4
</pre><p><strong>
示例 4:
</strong></p><pre><strong>
输入:
</strong>
[1,3,5,6], 0
<strong><br
/>
输出:
</strong>
0
</pre>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -25,6 +29,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -50,7 +55,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -77,6 +84,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -97,6 +105,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/1.leetcode-数组/47.旋转图像/solution.md
浏览文件 @
ceaae444
# 旋转图像
<p>给定一个 <em>n </em>× <em>n</em> 的二维矩阵 <code>matrix</code> 表示一个图像。请你将图像顺时针旋转 90 度。</p><p>你必须在<strong><a href="https://baike.baidu.com/item/%E5%8E%9F%E5%9C%B0%E7%AE%97%E6%B3%95" target="_blank"> 原地</a></strong> 旋转图像,这意味着你需要直接修改输入的二维矩阵。<strong>请不要 </strong>使用另一个矩阵来旋转图像。</p><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0048.Rotate%20Image/images/mat1.jpg" style="width: 642px; height: 242px;" /><pre><strong>输入:</strong>matrix = [[1,2,3],[4,5,6],[7,8,9]]<strong><br />输出:</strong>[[7,4,1],[8,5,2],[9,6,3]]</pre><p><strong>示例 2:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0048.Rotate%20Image/images/mat2.jpg" style="width: 800px; height: 321px;" /><pre><strong>输入:</strong>matrix = [[5,1,9,11],[2,4,8,10],[13,3,6,7],[15,14,12,16]]<strong><br />输出:</strong>[[15,13,2,5],[14,3,4,1],[12,6,8,9],[16,7,10,11]]</pre><p><strong>示例 3:</strong></p><pre><strong>输入:</strong>matrix = [[1]]<strong><br />输出:</strong>[[1]]</pre><p><strong>示例 4:</strong></p><pre><strong>输入:</strong>matrix = [[1,2],[3,4]]<strong><br />输出:</strong>[[3,1],[4,2]]</pre><p> </p><p><strong>提示:</strong></p><ul> <li><code>matrix.length == n</code></li> <li><code>matrix[i].length == n</code></li> <li><code>1 <= n <= 20</code></li> <li><code>-1000 <= matrix[i][j] <= 1000</code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -39,7 +44,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -64,6 +71,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -91,6 +99,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/1.leetcode-数组/53.螺旋矩阵/solution.md
浏览文件 @
ceaae444
# 螺旋矩阵
<p>给你一个 <code>m</code> 行 <code>n</code> 列的矩阵 <code>matrix</code> ,请按照 <strong>顺时针螺旋顺序</strong> ,返回矩阵中的所有元素。</p><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0054.Spiral%20Matrix/images/spiral1.jpg" style="width: 242px; height: 242px;" /><pre><strong>输入:</strong>matrix = [[1,2,3],[4,5,6],[7,8,9]]<strong><br />输出:</strong>[1,2,3,6,9,8,7,4,5]</pre><p><strong>示例 2:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0054.Spiral%20Matrix/images/spiral.jpg" style="width: 322px; height: 242px;" /><pre><strong>输入:</strong>matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]<strong><br />输出:</strong>[1,2,3,4,8,12,11,10,9,5,6,7]</pre><p> </p><p><strong>提示:</strong></p><ul> <li><code>m == matrix.length</code></li> <li><code>n == matrix[i].length</code></li> <li><code>1 <= m, n <= 10</code></li> <li><code>-100 <= matrix[i][j] <= 100</code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -68,7 +73,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -125,6 +132,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -159,6 +167,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/1.leetcode-数组/55.合并区间/solution.md
浏览文件 @
ceaae444
# 合并区间
<p>
以数组
<code>
intervals
</code>
表示若干个区间的集合,其中单个区间为
<code>
intervals[i] = [start
<sub>
i
</sub>
, end
<sub>
i
</sub>
]
</code>
。请你合并所有重叠的区间,并返回一个不重叠的区间数组,该数组需恰好覆盖输入中的所有区间。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
intervals = [[1,3],[2,6],[8,10],[15,18]]
<strong><br
/>
输出:
</strong>
[[1,6],[8,10],[15,18]]
<strong><br
/>
解释:
</strong>
区间 [1,3] 和 [2,6] 重叠, 将它们合并为 [1,6].
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
intervals = [[1,4],[4,5]]
<strong><br
/>
输出:
</strong>
[[1,5]]
<strong><br
/>
解释:
</strong>
区间 [1,4] 和 [4,5] 可被视为重叠区间。
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
1
<
=
intervals.length
<=
10<
sup
>
4
</sup></code></li>
<li><code>
intervals[i].length == 2
</code></li>
<li><code>
0
<
=
start
<
sub
>
i
</sub>
<
=
end
<
sub
>
i
</sub>
<
=
10<
sup
>
4
</sup></code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -48,7 +53,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -71,6 +78,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -97,6 +105,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/1.leetcode-数组/56.插入区间/solution.md
浏览文件 @
ceaae444
# 插入区间
<p>
给你一个
<strong>
无重叠的
</strong><em>
,
</em>
按照区间起始端点排序的区间列表。
</p>
<p>
在列表中插入一个新的区间,你需要确保列表中的区间仍然有序且不重叠(如果有必要的话,可以合并区间)。
</p>
<p>
</p>
...
...
@@ -25,17 +26,21 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -60,7 +65,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -197,6 +204,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -235,6 +243,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/1.leetcode-数组/58.螺旋矩阵 II/solution.md
浏览文件 @
ceaae444
# 螺旋矩阵 II
<p>给你一个正整数 <code>n</code> ,生成一个包含 <code>1</code> 到 <code>n<sup>2</sup></code> 所有元素,且元素按顺时针顺序螺旋排列的 <code>n x n</code> 正方形矩阵 <code>matrix</code> 。</p><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0059.Spiral%20Matrix%20II/images/spiraln.jpg" style="width: 242px; height: 242px;" /><pre><strong>输入:</strong>n = 3<strong><br />输出:</strong>[[1,2,3],[8,9,4],[7,6,5]]</pre><p><strong>示例 2:</strong></p><pre><strong>输入:</strong>n = 1<strong><br />输出:</strong>[[1]]</pre><p> </p><p><strong>提示:</strong></p><ul> <li><code>1 <= n <= 20</code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -28,6 +32,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -56,7 +61,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
...
...
@@ -97,6 +104,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -128,6 +136,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/1.leetcode-数组/72.矩阵置零/solution.md
浏览文件 @
ceaae444
# 矩阵置零
<p>给定一个 <code><em>m</em> x <em>n</em></code> 的矩阵,如果一个元素为 <strong>0 </strong>,则将其所在行和列的所有元素都设为 <strong>0</strong> 。请使用 <strong><a href="http://baike.baidu.com/item/%E5%8E%9F%E5%9C%B0%E7%AE%97%E6%B3%95" target="_blank">原地</a></strong> 算法<strong>。</strong></p><p><strong>进阶:</strong></p><ul> <li>一个直观的解决方案是使用 <code>O(<em>m</em><em>n</em>)</code> 的额外空间,但这并不是一个好的解决方案。</li> <li>一个简单的改进方案是使用 <code>O(<em>m</em> + <em>n</em>)</code> 的额外空间,但这仍然不是最好的解决方案。</li> <li>你能想出一个仅使用常量空间的解决方案吗?</li></ul><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0073.Set%20Matrix%20Zeroes/images/mat1.jpg" style="width: 450px; height: 169px;" /><pre><strong>输入:</strong>matrix = [[1,1,1],[1,0,1],[1,1,1]]<strong><br />输出:</strong>[[1,0,1],[0,0,0],[1,0,1]]</pre><p><strong>示例 2:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0073.Set%20Matrix%20Zeroes/images/mat2.jpg" style="width: 450px; height: 137px;" /><pre><strong>输入:</strong>matrix = [[0,1,2,0],[3,4,5,2],[1,3,1,5]]<strong><br />输出:</strong>[[0,0,0,0],[0,4,5,0],[0,3,1,0]]</pre><p> </p><p><strong>提示:</strong></p><ul> <li><code>m == matrix.length</code></li> <li><code>n == matrix[0].length</code></li> <li><code>1 <= m, n <= 200</code></li> <li><code>-2<sup>31</sup> <= matrix[i][j] <= 2<sup>31</sup> - 1</code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -28,6 +32,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -69,7 +74,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -140,6 +147,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -185,6 +193,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/1.leetcode-数组/73.搜索二维矩阵/solution.md
浏览文件 @
ceaae444
# 搜索二维矩阵
<p>编写一个高效的算法来判断 <code>m x n</code> 矩阵中,是否存在一个目标值。该矩阵具有如下特性:</p><ul> <li>每行中的整数从左到右按升序排列。</li> <li>每行的第一个整数大于前一行的最后一个整数。</li></ul><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0074.Search%20a%202D%20Matrix/images/mat.jpg" style="width: 322px; height: 242px;" /><pre><strong>输入:</strong>matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 3<strong><br />输出:</strong>true</pre><p><strong>示例 2:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0074.Search%20a%202D%20Matrix/images/mat2.jpg" style="width: 322px; height: 242px;" /><pre><strong>输入:</strong>matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 13<strong><br />输出:</strong>false</pre><p> </p><p><strong>提示:</strong></p><ul> <li><code>m == matrix.length</code></li> <li><code>n == matrix[i].length</code></li> <li><code>1 <= m, n <= 100</code></li> <li><code>-10<sup>4</sup> <= matrix[i][j], target <= 10<sup>4</sup></code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -27,6 +31,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -64,7 +69,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -117,6 +124,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -148,6 +156,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/1.leetcode-数组/77.子集/solution.md
浏览文件 @
ceaae444
# 子集
<p>
给你一个整数数组
<code>
nums
</code>
,数组中的元素
<strong>
互不相同
</strong>
。返回该数组所有可能的子集(幂集)。
</p><p>
解集
<strong>
不能
</strong>
包含重复的子集。你可以按
<strong>
任意顺序
</strong>
返回解集。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
nums = [1,2,3]
<strong><br
/>
输出:
</strong>
[[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
nums = [0]
<strong><br
/>
输出:
</strong>
[[],[0]]
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
1
<
=
nums.length
<=
10</
code
></li>
<li><code>
-10
<
=
nums
[
i
]
<=
10</
code
></li>
<li><code>
nums
</code>
中的所有元素
<strong>
互不相同
</strong></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -27,6 +31,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -57,7 +62,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -87,6 +94,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -117,6 +125,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/1.leetcode-数组/79.删除有序数组中的重复项 II/solution.md
浏览文件 @
ceaae444
# 删除有序数组中的重复项 II
<p>
给你一个有序数组
<code>
nums
</code>
,请你
<strong>
<a href="http://baike.baidu.com/item/%E5%8E%9F%E5%9C%B0%E7%AE%97%E6%B3%95"
target="_blank"> 原地
</a></strong>
删除重复出现的元素,使每个元素
<strong>
最多出现两次
</strong>
,返回删除后数组的新长度。
</p>
<p>
不要使用额外的数组空间,你必须在
<strong>
<a href="https://baike.baidu.com/item/%E5%8E%9F%E5%9C%B0%E7%AE%97%E6%B3%95"
...
...
@@ -30,12 +31,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -52,6 +56,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -77,7 +82,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -105,6 +112,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -129,6 +137,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/1.leetcode-数组/80.搜索旋转排序数组 II/solution.md
浏览文件 @
ceaae444
# 搜索旋转排序数组 II
<p>
已知存在一个按非降序排列的整数数组
<code>
nums
</code>
,数组中的值不必互不相同。
</p>
<p>
在传递给函数之前,
<code>
nums
</code>
在预先未知的某个下标
<code>
k
</code>
(
<code>
0
<
=
k
<
nums.length
</
code
>
)上进行了
<strong>
旋转
</strong>
,使数组变为
<code>
[nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]]
</code>
(下标
<strong>
从 0
...
...
@@ -32,12 +33,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -52,6 +56,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -104,7 +109,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -152,6 +159,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -219,6 +227,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/2.leetcode-链表/1.两数相加/solution.md
浏览文件 @
ceaae444
# 两数相加
<p>给你两个 <strong>非空</strong> 的链表,表示两个非负的整数。它们每位数字都是按照 <strong>逆序</strong> 的方式存储的,并且每个节点只能存储 <strong>一位</strong> 数字。</p><p>请你将两个数相加,并以相同形式返回一个表示和的链表。</p><p>你可以假设除了数字 0 之外,这两个数都不会以 0 开头。</p><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0002.Add%20Two%20Numbers/images/addtwonumber1.jpg" style="width: 483px; height: 342px;" /><pre><strong>输入:</strong>l1 = [2,4,3], l2 = [5,6,4]<strong><br />输出:</strong>[7,0,8]<strong><br />解释:</strong>342 + 465 = 807.</pre><p><strong>示例 2:</strong></p><pre><strong>输入:</strong>l1 = [0], l2 = [0]<strong><br />输出:</strong>[0]</pre><p><strong>示例 3:</strong></p><pre><strong>输入:</strong>l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9]<strong><br />输出:</strong>[8,9,9,9,0,0,0,1]</pre><p> </p><p><strong>提示:</strong></p><ul> <li>每个链表中的节点数在范围 <code>[1, 100]</code> 内</li> <li><code>0 <= Node.val <= 9</code></li> <li>题目数据保证列表表示的数字不含前导零</li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <unordered_map>
#include <vector>
...
...
@@ -21,6 +24,7 @@ struct ListNode
};
```
### after
```
cpp
int
main
()
...
...
@@ -61,6 +65,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -101,7 +106,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -146,6 +153,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -198,6 +206,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/2.leetcode-链表/18.删除链表的倒数第 N 个结点/solution.md
浏览文件 @
ceaae444
# 删除链表的倒数第 N 个结点
<p>给你一个链表,删除链表的倒数第 <code>n</code><em> </em>个结点,并且返回链表的头结点。</p><p><strong>进阶:</strong>你能尝试使用一趟扫描实现吗?</p><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0019.Remove%20Nth%20Node%20From%20End%20of%20List/images/remove_ex1.jpg" style="width: 542px; height: 222px;" /><pre><strong>输入:</strong>head = [1,2,3,4,5], n = 2<strong><br />输出:</strong>[1,2,3,5]</pre><p><strong>示例 2:</strong></p><pre><strong>输入:</strong>head = [1], n = 1<strong><br />输出:</strong>[]</pre><p><strong>示例 3:</strong></p><pre><strong>输入:</strong>head = [1,2], n = 1<strong><br />输出:</strong>[1]</pre><p> </p><p><strong>提示:</strong></p><ul> <li>链表中结点的数目为 <code>sz</code></li> <li><code>1 <= sz <= 30</code></li> <li><code>0 <= Node.val <= 100</code></li> <li><code>1 <= n <= sz</code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -18,6 +21,7 @@ struct ListNode
};
```
### after
```
cpp
int
main
()
{
...
...
@@ -53,6 +57,7 @@ int main()
```
## 答案
```
cpp
class
Solution
...
...
@@ -92,7 +97,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -128,6 +135,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -156,6 +164,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/2.leetcode-链表/20.合并两个有序链表/solution.md
浏览文件 @
ceaae444
# 合并两个有序链表
<p>将两个升序链表合并为一个新的 <strong>升序</strong> 链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。 </p><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0021.Merge%20Two%20Sorted%20Lists/images/merge_ex1.jpg" style="width: 662px; height: 302px;" /><pre><strong>输入:</strong>l1 = [1,2,4], l2 = [1,3,4]<strong><br />输出:</strong>[1,1,2,3,4,4]</pre><p><strong>示例 2:</strong></p><pre><strong>输入:</strong>l1 = [], l2 = []<strong><br />输出:</strong>[]</pre><p><strong>示例 3:</strong></p><pre><strong>输入:</strong>l1 = [], l2 = [0]<strong><br />输出:</strong>[0]</pre><p> </p><p><strong>提示:</strong></p><ul> <li>两个链表的节点数目范围是 <code>[0, 50]</code></li> <li><code>-100 <= Node.val <= 100</code></li> <li><code>l1</code> 和 <code>l2</code> 均按 <strong>非递减顺序</strong> 排列</li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -18,6 +21,7 @@ struct ListNode
};
```
### after
```
cpp
int
main
()
{
...
...
@@ -57,6 +61,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -82,7 +87,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -134,6 +141,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -179,6 +187,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/2.leetcode-链表/22.合并K个升序链表/solution.md
浏览文件 @
ceaae444
# 合并K个升序链表
<p>
给你一个链表数组,每个链表都已经按升序排列。
</p><p>
请你将所有链表合并到一个升序链表中,返回合并后的链表。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
lists =
[
[1,4,5],[1,3,4],[2,6]]<strong><br />输出:</strong>[1,1,2,3,4,4,5,6]<strong><br />解释:</strong>链表数组如下:[ 1->4->5, 1->3->4, 2->6]将它们合并到一个有序链表中得到。1->1->2->3->4->4->5->6</pre><p><strong>示例 2:</strong></p><pre><strong>输入:</strong>lists = []<strong><br />输出:</strong>[]</pre><p><strong>示例 3:</strong></p><pre><strong>输入:</strong>lists = [[]]<strong><br />输出:</strong>[]</pre><p> </p><p><strong>提示:</strong></p><ul> <li><code>k == lists.length</code></li> <li><code>0 <= k <= 10^4</code></li> <li><code>0 <= lists[i].length <= 500</code></li> <li><code>-10^4 <= lists[i
][
j
]
<
= 10^4
</code></li>
<li><code>
lists[i]
</code>
按
<strong>
升序
</strong>
排列
</li>
<li><code>
lists[i].length
</code>
的总和不超过
<code>
10^4
</code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -18,6 +21,7 @@ struct ListNode
};
```
### after
```
cpp
int
main
()
{
...
...
@@ -66,6 +70,7 @@ int main()
```
## 答案
```
cpp
struct
cmp
{
...
...
@@ -106,7 +111,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -158,6 +165,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -203,6 +211,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/2.leetcode-链表/23.两两交换链表中的节点/solution.md
浏览文件 @
ceaae444
# 两两交换链表中的节点
<p>给定一个链表,两两交换其中相邻的节点,并返回交换后的链表。</p><p><strong>你不能只是单纯的改变节点内部的值</strong>,而是需要实际的进行节点交换。</p><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0024.Swap%20Nodes%20in%20Pairs/images/swap_ex1.jpg" style="width: 422px; height: 222px;" /><pre><strong>输入:</strong>head = [1,2,3,4]<strong><br />输出:</strong>[2,1,4,3]</pre><p><strong>示例 2:</strong></p><pre><strong>输入:</strong>head = []<strong><br />输出:</strong>[]</pre><p><strong>示例 3:</strong></p><pre><strong>输入:</strong>head = [1]<strong><br />输出:</strong>[1]</pre><p> </p><p><strong>提示:</strong></p><ul> <li>链表中节点的数目在范围 <code>[0, 100]</code> 内</li> <li><code>0 <= Node.val <= 100</code></li></ul><p> </p><p><strong>进阶:</strong>你能在不修改链表节点值的情况下解决这个问题吗?(也就是说,仅修改节点本身。)</p>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -18,11 +21,13 @@ struct ListNode
};
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -54,7 +59,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
...
...
@@ -90,6 +97,7 @@ public:
```
### B
```
cpp
class
Solution
{
public:
...
...
@@ -106,6 +114,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/2.leetcode-链表/24.K 个一组翻转链表/solution.md
浏览文件 @
ceaae444
# K 个一组翻转链表
<p>给你一个链表,每 <em>k </em>个节点一组进行翻转,请你返回翻转后的链表。</p><p><em>k </em>是一个正整数,它的值小于或等于链表的长度。</p><p>如果节点总数不是 <em>k </em>的整数倍,那么请将最后剩余的节点保持原有顺序。</p><p><strong>进阶:</strong></p><ul> <li>你可以设计一个只使用常数额外空间的算法来解决此问题吗?</li> <li><strong>你不能只是单纯的改变节点内部的值</strong>,而是需要实际进行节点交换。</li></ul><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0025.Reverse%20Nodes%20in%20k-Group/images/reverse_ex1.jpg" style="width: 542px; height: 222px;" /><pre><strong>输入:</strong>head = [1,2,3,4,5], k = 2<strong><br />输出:</strong>[2,1,4,3,5]</pre><p><strong>示例 2:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0025.Reverse%20Nodes%20in%20k-Group/images/reverse_ex2.jpg" style="width: 542px; height: 222px;" /><pre><strong>输入:</strong>head = [1,2,3,4,5], k = 3<strong><br />输出:</strong>[3,2,1,4,5]</pre><p><strong>示例 3:</strong></p><pre><strong>输入:</strong>head = [1,2,3,4,5], k = 1<strong><br />输出:</strong>[1,2,3,4,5]</pre><p><strong>示例 4:</strong></p><pre><strong>输入:</strong>head = [1], k = 1<strong><br />输出:</strong>[1]</pre><ul></ul><p><strong>提示:</strong></p><ul> <li>列表中节点的数量在范围 <code>sz</code> 内</li> <li><code>1 <= sz <= 5000</code></li> <li><code>0 <= Node.val <= 1000</code></li> <li><code>1 <= k <= sz</code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
struct
ListNode
{
...
...
@@ -15,11 +18,13 @@ struct ListNode
};
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -89,7 +94,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -151,6 +158,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -193,6 +201,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/2.leetcode-链表/81.删除排序链表中的重复元素 II/solution.md
浏览文件 @
ceaae444
# 删除排序链表中的重复元素 II
<p>存在一个按升序排列的链表,给你这个链表的头节点 <code>head</code> ,请你删除链表中所有存在数字重复情况的节点,只保留原始链表中 <strong>没有重复出现</strong><em> </em>的数字。</p><p>返回同样按升序排列的结果链表。</p><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0082.Remove%20Duplicates%20from%20Sorted%20List%20II/images/linkedlist1.jpg" style="width: 500px; height: 142px;" /><pre><strong>输入:</strong>head = [1,2,3,3,4,4,5]<strong><br />输出:</strong>[1,2,5]</pre><p><strong>示例 2:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0082.Remove%20Duplicates%20from%20Sorted%20List%20II/images/linkedlist2.jpg" style="width: 500px; height: 205px;" /><pre><strong>输入:</strong>head = [1,1,1,2,3]<strong><br />输出:</strong>[2,3]</pre><p> </p><p><strong>提示:</strong></p><ul> <li>链表中节点数目在范围 <code>[0, 300]</code> 内</li> <li><code>-100 <= Node.val <= 100</code></li> <li>题目数据保证链表已经按升序排列</li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -16,11 +19,13 @@ struct ListNode
};
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -53,7 +58,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -78,6 +85,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -118,6 +126,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/2.leetcode-链表/82.删除排序链表中的重复元素/solution.md
浏览文件 @
ceaae444
# 删除排序链表中的重复元素
<p>存在一个按升序排列的链表,给你这个链表的头节点 <code>head</code> ,请你删除所有重复的元素,使每个元素 <strong>只出现一次</strong> 。</p><p>返回同样按升序排列的结果链表。</p><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0083.Remove%20Duplicates%20from%20Sorted%20List/images/list1.jpg" style="width: 302px; height: 242px;" /><pre><strong>输入:</strong>head = [1,1,2]<strong><br />输出:</strong>[1,2]</pre><p><strong>示例 2:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0083.Remove%20Duplicates%20from%20Sorted%20List/images/list2.jpg" style="width: 542px; height: 222px;" /><pre><strong>输入:</strong>head = [1,1,2,3,3]<strong><br />输出:</strong>[1,2,3]</pre><p> </p><p><strong>提示:</strong></p><ul> <li>链表中节点数目在范围 <code>[0, 300]</code> 内</li> <li><code>-100 <= Node.val <= 100</code></li> <li>题目数据保证链表已经按升序排列</li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -16,11 +19,13 @@ struct ListNode
};
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -38,7 +43,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -73,6 +80,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -96,6 +104,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/2.leetcode-链表/85.分隔链表/solution.md
浏览文件 @
ceaae444
# 分隔链表
<p>给你一个链表的头节点 <code>head</code> 和一个特定值<em> </em><code>x</code> ,请你对链表进行分隔,使得所有 <strong>小于</strong> <code>x</code> 的节点都出现在 <strong>大于或等于</strong> <code>x</code> 的节点之前。</p><p>你应当 <strong>保留</strong> 两个分区中每个节点的初始相对位置。</p><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0086.Partition%20List/images/partition.jpg" style="width: 662px; height: 222px;" /><pre><strong>输入:</strong>head = [1,4,3,2,5,2], x = 3<strong><br />输出</strong>:[1,2,2,4,3,5]</pre><p><strong>示例 2:</strong></p><pre><strong>输入:</strong>head = [2,1], x = 2<strong><br />输出</strong>:[1,2]</pre><p> </p><p><strong>提示:</strong></p><ul> <li>链表中节点的数目在范围 <code>[0, 200]</code> 内</li> <li><code>-100 <= Node.val <= 100</code></li> <li><code>-200 <= x <= 200</code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -16,11 +19,13 @@ struct ListNode
};
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -65,7 +70,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -100,6 +107,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -132,6 +140,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/2.leetcode-链表/91.反转链表 II/solution.md
浏览文件 @
ceaae444
# 反转链表 II
给你单链表的头指针
<code>head</code> 和两个整数 <code>left</code> 和 <code>right</code> ,其中 <code>left <= right</code> 。请你反转从位置 <code>left</code> 到位置 <code>right</code> 的链表节点,返回 <strong>反转后的链表</strong> 。<p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0092.Reverse%20Linked%20List%20II/images/rev2ex2.jpg" style="width: 542px; height: 222px;" /><pre><strong>输入:</strong>head = [1,2,3,4,5], left = 2, right = 4<strong><br />输出:</strong>[1,4,3,2,5]</pre><p><strong>示例 2:</strong></p><pre><strong>输入:</strong>head = [5], left = 1, right = 1<strong><br />输出:</strong>[5]</pre><p> </p><p><strong>提示:</strong></p><ul> <li>链表中节点数目为 <code>n</code></li> <li><code>1 <= n <= 500</code></li> <li><code>-500 <= Node.val <= 500</code></li> <li><code>1 <= left <= right <= n</code></li></ul><p> </p><p><strong>进阶:</strong> 你可以使用一趟扫描完成反转吗?</p>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -16,11 +19,13 @@ struct ListNode
};
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -45,7 +50,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -88,6 +95,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -126,6 +134,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/3.leetcode-字符串/13.最长公共前缀/solution.md
浏览文件 @
ceaae444
# 最长公共前缀
<p>
编写一个函数来查找字符串数组中的最长公共前缀。
</p><p>
如果不存在公共前缀,返回空字符串
<code>
""
</code>
。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
strs = ["flower","flow","flight"]
<strong><br
/>
输出:
</strong>
"fl"
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
strs = ["dog","racecar","car"]
<strong><br
/>
输出:
</strong>
""
<strong><br
/>
解释:
</strong>
输入不存在公共前缀。
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
0
<
=
strs.length
<=
200</
code
></li>
<li><code>
0
<
=
strs
[
i
].
length
<=
200</
code
></li>
<li><code>
strs[i]
</code>
仅由小写英文字母组成
</li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -22,6 +26,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -45,7 +50,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -82,6 +89,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -119,6 +127,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/3.leetcode-字符串/2.无重复字符的最长子串/solution.md
浏览文件 @
ceaae444
# 无重复字符的最长子串
<p>
给定一个字符串,请你找出其中不含有重复字符的
<strong>
最长子串
</strong>
的长度。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
s = "abcabcbb"
<strong><br
/>
输出:
</strong>
3
<strong><br
/>
解释:
</strong>
因为无重复字符的最长子串是 "abc",所以其长度为 3。
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
s = "bbbbb"
<strong><br
/>
输出:
</strong>
1
<strong><br
/>
解释:
</strong>
因为无重复字符的最长子串是 "b",所以其长度为 1。
</pre><p><strong>
示例 3:
</strong></p><pre><strong>
输入:
</strong>
s = "pwwkew"
<strong><br
/>
输出:
</strong>
3
<strong><br
/>
解释:
</strong>
因为无重复字符的最长子串是 "wke",所以其长度为 3。
请注意,你的答案必须是
<strong>
子串
</strong>
的长度,"pwke" 是一个
<em>
子序列,
</em>
不是子串。
</pre><p><strong>
示例 4:
</strong></p><pre><strong>
输入:
</strong>
s = ""
<strong><br
/>
输出:
</strong>
0
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
0
<
=
s.length
<=
5
*
10<
sup
>
4
</sup></code></li>
<li><code>
s
</code>
由英文字母、数字、符号和空格组成
</li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -23,6 +27,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -57,7 +62,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -80,6 +87,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -107,6 +115,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/3.leetcode-字符串/27.实现 strStr()/solution.md
浏览文件 @
ceaae444
# 实现 strStr()
<p>
实现
<a
href=
"https://baike.baidu.com/item/strstr/811469"
target=
"_blank"
>
strStr()
</a>
函数。
</p>
<p>
给你两个字符串
<code>
haystack
</code>
和
<code>
needle
</code>
,请你在
<code>
haystack
</code>
字符串中找出
<code>
needle
</code>
字符串出现的第一个位置(下标从 0 开始)。如果不存在,则返回
<code>
-1
</code><strong>
</strong>
。
</p>
...
...
@@ -25,12 +26,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -43,6 +47,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -55,7 +60,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -87,6 +94,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -144,6 +152,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/3.leetcode-字符串/37.外观数列/solution.md
浏览文件 @
ceaae444
# 外观数列
<div
class=
"notranslate"
>
<p>
给定一个正整数
<code>
n
</code>
,输出外观数列的第
<code>
n
</code>
项。
</p>
...
...
@@ -67,12 +68,15 @@ countAndSay(4) = 读 "21" = 一 个 2 + 一 个 1 = "12" + "11" = "1211"
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
...
...
@@ -89,6 +93,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -115,7 +120,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -175,6 +182,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -237,6 +245,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/3.leetcode-字符串/42.字符串相乘/solution.md
浏览文件 @
ceaae444
# 字符串相乘
<p>
给定两个以字符串形式表示的非负整数
<code>
num1
</code>
和
<code>
num2
</code>
,返回
<code>
num1
</code>
和
<code>
num2
</code>
的乘积,它们的乘积也表示为字符串形式。
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
num1 =
"
2
"
, num2 =
"
3
"
<strong><br
/>
输出:
</strong>
"
6
"
</pre><p><strong>
示例
2:
</strong></p><pre><strong>
输入:
</strong>
num1 =
"
123
"
, num2 =
"
456
"
<strong><br
/>
输出:
</strong>
"
56088
"
</pre><p><strong>
说明:
</strong></p><ol>
<li><code>
num1
</code>
和
<code>
num2
</code>
的长度小于110。
</li>
<li><code>
num1
</code>
和
<code>
num2
</code>
只包含数字
<code>
0-9
</code>
。
</li>
<li><code>
num1
</code>
和
<code>
num2
</code>
均不以零开头,除非是数字 0 本身。
</li>
<li><strong>
不能使用任何标准库的大数类型(比如 BigInteger)
</strong>
或
<strong>
直接将输入转换为整数来处理
</strong>
。
</li></ol>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -24,6 +28,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -56,7 +61,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -89,6 +96,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -133,6 +141,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/3.leetcode-字符串/5.Z 字形变换/solution.md
浏览文件 @
ceaae444
# Z 字形变换
<div
class=
"notranslate"
>
<p>
将一个给定字符串
<code>
s
</code>
根据给定的行数
<code>
numRows
</code>
,以从上往下、从左到右进行
Z 字形排列。
</p>
...
...
@@ -52,12 +53,15 @@ P I
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -74,6 +78,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -122,7 +127,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -152,6 +159,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -179,6 +187,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/3.leetcode-字符串/57.最后一个单词的长度/solution.md
浏览文件 @
ceaae444
# 最后一个单词的长度
<p>
给你一个字符串
<code>
s
</code>
,由若干单词组成,单词之间用空格隔开。返回字符串中最后一个单词的长度。如果不存在最后一个单词,请返回 0 。
</p><p><strong>
单词
</strong>
是指仅由字母组成、不包含任何空格字符的最大子字符串。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
s = "Hello World"
<strong><br
/>
输出:
</strong>
5
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
s = " "
<strong><br
/>
输出:
</strong>
0
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
1
<
=
s.length
<=
10<
sup
>
4
</sup></code></li>
<li><code>
s
</code>
仅有英文字母和空格
<code>
' '
</code>
组成
</li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -23,6 +27,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -45,7 +50,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -63,6 +70,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -90,6 +98,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/3.leetcode-字符串/64.有效数字/solution.md
浏览文件 @
ceaae444
# 有效数字
<p><strong>
有效数字
</strong>
(按顺序)可以分成以下几个部分:
</p><ol>
<li>
一个
<strong>
小数
</strong>
或者
<strong>
整数
</strong></li>
<li>
(可选)一个
<code>
'e'
</code>
或
<code>
'E'
</code>
,后面跟着一个
<strong>
整数
</strong></li></ol><p><strong>
小数
</strong>
(按顺序)可以分成以下几个部分:
</p><ol>
<li>
(可选)一个符号字符(
<code>
'+'
</code>
或
<code>
'-'
</code>
)
</li>
<li>
下述格式之一:
<ol>
<li>
至少一位数字,后面跟着一个点
<code>
'.'
</code></li>
<li>
至少一位数字,后面跟着一个点
<code>
'.'
</code>
,后面再跟着至少一位数字
</li>
<li>
一个点
<code>
'.'
</code>
,后面跟着至少一位数字
</li>
</ol>
</li></ol><p><strong>
整数
</strong>
(按顺序)可以分成以下几个部分:
</p><ol>
<li>
(可选)一个符号字符(
<code>
'+'
</code>
或
<code>
'-'
</code>
)
</li>
<li>
至少一位数字
</li></ol><p>
部分有效数字列举如下:
</p><ul>
<li><code>
["2", "0089", "-0.1", "+3.14", "4.", "-.9", "2e10", "-90E3", "3e+7", "+6e-1", "53.5e93", "-123.456e789"]
</code></li></ul><p>
部分无效数字列举如下:
</p><ul>
<li><code>
["abc", "1a", "1e", "e3", "99e2.5", "--6", "-+3", "95a54e53"]
</code></li></ul><p>
给你一个字符串
<code>
s
</code>
,如果
<code>
s
</code>
是一个
<strong>
有效数字
</strong>
,请返回
<code>
true
</code>
。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
s = "0"
<strong><br
/>
输出:
</strong>
true
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
s = "e"
<strong><br
/>
输出:
</strong>
false
</pre><p><strong>
示例 3:
</strong></p><pre><strong>
输入:
</strong>
s = "."
<strong><br
/>
输出:
</strong>
false
</pre><p><strong>
示例 4:
</strong></p><pre><strong>
输入:
</strong>
s = ".1"
<strong><br
/>
输出:
</strong>
true
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
1
<
=
s.length
<=
20</
code
></li>
<li><code>
s
</code>
仅含英文字母(大写和小写),数字(
<code>
0-9
</code>
),加号
<code>
'+'
</code>
,减号
<code>
'-'
</code>
,或者点
<code>
'.'
</code>
。
</li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -22,6 +26,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -85,7 +90,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -147,6 +154,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -224,6 +232,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/3.leetcode-字符串/7.字符串转换整数 (atoi)/solution.md
浏览文件 @
ceaae444
# 字符串转换整数 (atoi)
<div
class=
"notranslate"
>
<p>
请你来实现一个
<code>
myAtoi(string s)
</code>
函数,使其能将字符串转换成一个 32 位有符号整数(类似 C/C++ 中的
<code>
atoi
</code>
函数)。
</p>
...
...
@@ -111,12 +112,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -127,6 +131,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -167,7 +172,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -183,6 +190,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -231,6 +239,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/3.leetcode-字符串/92.复原 IP 地址/solution.md
浏览文件 @
ceaae444
# 复原 IP 地址
<p>给定一个只包含数字的字符串,用以表示一个 IP 地址,返回所有可能从 <code>s</code> 获得的 <strong>有效 IP 地址 </strong>。你可以按任何顺序返回答案。</p><p><strong>有效 IP 地址</strong> 正好由四个整数(每个整数位于 0 到 255 之间组成,且不能含有前导 <code>0</code>),整数之间用 <code>'.'</code> 分隔。</p><p>例如:"0.1.2.201" 和 "192.168.1.1" 是 <strong>有效</strong> IP 地址,但是 "0.011.255.245"、"192.168.1.312" 和 "192.168@1.1" 是 <strong>无效</strong> IP 地址。</p><p> </p><p><strong>示例 1:</strong></p><pre><strong>输入:</strong>s = "25525511135"<strong><br />输出:</strong>["255.255.11.135","255.255.111.35"]</pre><p><strong>示例 2:</strong></p><pre><strong>输入:</strong>s = "0000"<strong><br />输出:</strong>["0.0.0.0"]</pre><p><strong>示例 3:</strong></p><pre><strong>输入:</strong>s = "1111"<strong><br />输出:</strong>["1.1.1.1"]</pre><p><strong>示例 4:</strong></p><pre><strong>输入:</strong>s = "010010"<strong><br />输出:</strong>["0.10.0.10","0.100.1.0"]</pre><p><strong>示例 5:</strong></p><pre><strong>输入:</strong>s = "101023"<strong><br />输出:</strong>["1.0.10.23","1.0.102.3","10.1.0.23","10.10.2.3","101.0.2.3"]</pre><p> </p><p><strong>提示:</strong></p><ul> <li><code>0 <= s.length <= 3000</code></li> <li><code>s</code> 仅由数字组成</li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -23,6 +27,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -90,7 +95,9 @@ private:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -143,6 +150,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -183,6 +191,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/3.leetcode-字符串/96.交错字符串/solution.md
浏览文件 @
ceaae444
# 交错字符串
<p>给定三个字符串 <code>s1</code>、<code>s2</code>、<code>s3</code>,请你帮忙验证 <code>s3</code> 是否是由 <code>s1</code> 和 <code>s2</code><em> </em><strong>交错 </strong>组成的。</p><p>两个字符串 <code>s</code> 和 <code>t</code> <strong>交错</strong> 的定义与过程如下,其中每个字符串都会被分割成若干 <strong>非空</strong> 子字符串:</p><ul> <li><code>s = s<sub>1</sub> + s<sub>2</sub> + ... + s<sub>n</sub></code></li> <li><code>t = t<sub>1</sub> + t<sub>2</sub> + ... + t<sub>m</sub></code></li> <li><code>|n - m| <= 1</code></li> <li><strong>交错</strong> 是 <code>s<sub>1</sub> + t<sub>1</sub> + s<sub>2</sub> + t<sub>2</sub> + s<sub>3</sub> + t<sub>3</sub> + ...</code> 或者 <code>t<sub>1</sub> + s<sub>1</sub> + t<sub>2</sub> + s<sub>2</sub> + t<sub>3</sub> + s<sub>3</sub> + ...</code></li></ul><p><strong>提示:</strong><code>a + b</code> 意味着字符串 <code>a</code> 和 <code>b</code> 连接。</p><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0097.Interleaving%20String/images/interleave.jpg" style="width: 561px; height: 203px;" /><pre><strong>输入:</strong>s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac"<strong><br />输出:</strong>true</pre><p><strong>示例 2:</strong></p><pre><strong>输入:</strong>s1 = "aabcc", s2 = "dbbca", s3 = "aadbbbaccc"<strong><br />输出:</strong>false</pre><p><strong>示例 3:</strong></p><pre><strong>输入:</strong>s1 = "", s2 = "", s3 = ""<strong><br />输出:</strong>true</pre><p> </p><p><strong>提示:</strong></p><ul> <li><code>0 <= s1.length, s2.length <= 100</code></li> <li><code>0 <= s3.length <= 200</code></li> <li><code>s1</code>、<code>s2</code>、和 <code>s3</code> 都由小写英文字母组成</li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -24,6 +28,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -60,7 +65,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -99,6 +106,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -125,6 +133,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/4.leetcode-栈与队列/149.逆波兰表达式求值/solution.md
浏览文件 @
ceaae444
# 逆波兰表达式求值
<p>
根据
<a
href=
"https://baike.baidu.com/item/%E9%80%86%E6%B3%A2%E5%85%B0%E5%BC%8F/128437"
target=
"_blank"
>
逆波兰表示法
</a>
,求表达式的值。
</p>
<p>
有效的算符包括
<code>
+
</code>
、
<code>
-
</code>
、
<code>
*
</code>
、
<code>
/
</code>
。每个运算对象可以是整数,也可以是另一个逆波兰表达式。
</p>
...
...
@@ -75,17 +76,21 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -133,7 +138,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -183,6 +190,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -236,6 +244,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/4.leetcode-栈与队列/154.最小栈/solution.md
浏览文件 @
ceaae444
# 最小栈
<p>
设计一个支持
<code>
push
</code>
,
<code>
pop
</code>
,
<code>
top
</code>
操作,并能在常数时间内检索到最小元素的栈。
</p>
<ul>
...
...
@@ -41,12 +42,15 @@ minStack.getMin(); --> 返回 -2.
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
/**
* Your MinStack object will be instantiated and called as such:
...
...
@@ -59,12 +63,15 @@ using namespace std;
```
## 答案
```
cpp
其他三个都是错的
```
## 选项
### A
```
cpp
class
MinStack
{
...
...
@@ -125,6 +132,7 @@ public:
```
### B
```
cpp
class
MinStack
{
...
...
@@ -180,6 +188,7 @@ public:
```
### C
```
cpp
class
MinStack
{
...
...
data/2.算法中阶/4.leetcode-栈与队列/19.有效的括号/solution.md
浏览文件 @
ceaae444
# 有效的括号
<p>
给定一个只包括
<code>
'('
</code>
,
<code>
')'
</code>
,
<code>
'{'
</code>
,
<code>
'}'
</code>
,
<code>
'['
</code>
,
<code>
']'
</code>
的字符串
<code>
s
</code>
,判断字符串是否有效。
</p><p>
有效字符串需满足:
</p><ol>
<li>
左括号必须用相同类型的右括号闭合。
</li>
<li>
左括号必须以正确的顺序闭合。
</li></ol><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
s = "()"
<strong><br
/>
输出:
</strong>
true
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
s = "()[]{}"
<strong><br
/>
输出:
</strong>
true
</pre><p><strong>
示例 3:
</strong></p><pre><strong>
输入:
</strong>
s = "(]"
<strong><br
/>
输出:
</strong>
false
</pre><p><strong>
示例 4:
</strong></p><pre><strong>
输入:
</strong>
s = "([)]"
<strong><br
/>
输出:
</strong>
false
</pre><p><strong>
示例 5:
</strong></p><pre><strong>
输入:
</strong>
s = "{[]}"
<strong><br
/>
输出:
</strong>
true
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
1
<
=
s.length
<=
10<
sup
>
4
</sup></code></li>
<li><code>
s
</code>
仅由括号
<code>
'()[]{}'
</code>
组成
</li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -23,6 +27,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -62,7 +67,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -94,6 +101,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -149,6 +157,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/4.leetcode-栈与队列/217.天际线问题/solution.md
浏览文件 @
ceaae444
# 天际线问题
<p>
城市的天际线是从远处观看该城市中所有建筑物形成的轮廓的外部轮廓。给你所有建筑物的位置和高度,请返回由这些建筑物形成的
<strong>
天际线
</strong>
。
</p>
<p>
每个建筑物的几何信息由数组
<code>
buildings
</code>
表示,其中三元组
<code>
buildings[i] = [lefti, righti, heighti]
</code>
表示:
</p>
...
...
@@ -45,16 +46,20 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -91,7 +96,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -132,6 +139,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -169,6 +177,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/4.leetcode-栈与队列/223.基本计算器/solution.md
浏览文件 @
ceaae444
# 基本计算器
<p>
给你一个字符串表达式
<code>
s
</code>
,请你实现一个基本计算器来计算并返回它的值。
</p>
<p>
</p>
...
...
@@ -37,12 +38,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -56,6 +60,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -170,7 +175,9 @@ private:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -253,6 +260,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -362,6 +370,7 @@ private:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/4.leetcode-栈与队列/226.基本计算器 II/solution.md
浏览文件 @
ceaae444
# 基本计算器 II
<p>
给你一个字符串表达式
<code>
s
</code>
,请你实现一个基本计算器来计算并返回它的值。
</p>
<p>
整数除法仅保留整数部分。
</p>
...
...
@@ -45,12 +46,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -64,6 +68,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -136,7 +141,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -192,6 +199,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -260,6 +268,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/4.leetcode-栈与队列/31.最长有效括号/solution.md
浏览文件 @
ceaae444
# 最长有效括号
<p>
给你一个只包含
<code>
'('
</code>
和
<code>
')'
</code>
的字符串,找出最长有效(格式正确且连续)括号子串的长度。
</p><p>
</p><div
class=
"original__bRMd"
><div><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
s = "(()"
<strong><br
/>
输出:
</strong>
2
<strong><br
/>
解释:
</strong>
最长有效括号子串是 "()"
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
s = ")()())"
<strong><br
/>
输出:
</strong>
4
<strong><br
/>
解释:
</strong>
最长有效括号子串是 "()()"
</pre><p><strong>
示例 3:
</strong></p><pre><strong>
输入:
</strong>
s = ""
<strong><br
/>
输出:
</strong>
0
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
0
<
=
s.length
<=
3
*
10<
sup
>
4
</sup></code></li>
<li><code>
s[i]
</code>
为
<code>
'('
</code>
或
<code>
')'
</code></li></ul></div></div>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -49,7 +54,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -91,6 +98,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -126,6 +134,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/4.leetcode-栈与队列/41.接雨水/solution.md
浏览文件 @
ceaae444
# 接雨水
<p>给定 <em>n</em> 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。</p><p> </p><p><strong>示例 1:</strong></p><p><img src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0042.Trapping%20Rain%20Water/images/rainwatertrap.png" style="height: 161px; width: 412px;" /></p><pre><strong>输入:</strong>height = [0,1,0,2,1,0,1,3,2,1,2,1]<strong><br />输出:</strong>6<strong><br />解释:</strong>上面是由数组 [0,1,0,2,1,0,1,3,2,1,2,1] 表示的高度图,在这种情况下,可以接 6 个单位的雨水(蓝色部分表示雨水)。 </pre><p><strong>示例 2:</strong></p><pre><strong>输入:</strong>height = [4,2,0,3,2,5]<strong><br />输出:</strong>9</pre><p> </p><p><strong>提示:</strong></p><ul> <li><code>n == height.length</code></li> <li><code>0 <= n <= 3 * 10<sup>4</sup></code></li> <li><code>0 <= height[i] <= 10<sup>5</sup></code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -24,6 +28,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -58,7 +63,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -101,6 +108,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -126,6 +134,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/4.leetcode-栈与队列/70.简化路径/solution.md
浏览文件 @
ceaae444
# 简化路径
<p>
给你一个字符串
<code>
path
</code>
,表示指向某一文件或目录的 Unix 风格
<strong>
绝对路径
</strong>
(以
<code>
'/'
</code>
开头),请你将其转化为更加简洁的规范路径。
</p><p
class=
"MachineTrans-lang-zh-CN"
>
在 Unix 风格的文件系统中,一个点(
<code>
.
</code>
)表示当前目录本身;此外,两个点 (
<code>
..
</code>
) 表示将目录切换到上一级(指向父目录);两者都可以是复杂相对路径的组成部分。任意多个连续的斜杠(即,
<code>
'//'
</code>
)都被视为单个斜杠
<code>
'/'
</code>
。 对于此问题,任何其他格式的点(例如,
<code>
'...'
</code>
)均被视为文件/目录名称。
</p><p>
请注意,返回的
<strong>
规范路径
</strong>
必须遵循下述格式:
</p><ul>
<li>
始终以斜杠
<code>
'/'
</code>
开头。
</li>
<li>
两个目录名之间必须只有一个斜杠
<code>
'/'
</code>
。
</li>
<li>
最后一个目录名(如果存在)
<strong>
不能
</strong>
以
<code>
'/'
</code>
结尾。
</li>
<li>
此外,路径仅包含从根目录到目标文件或目录的路径上的目录(即,不含
<code>
'.'
</code>
或
<code>
'..'
</code>
)。
</li></ul><p>
返回简化后得到的
<strong>
规范路径
</strong>
。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
path = "/home/"
<strong><br
/>
输出:
</strong>
"/home"
<strong><br
/>
解释:
</strong>
注意,最后一个目录名后面没有斜杠。
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
path = "/../"
<strong><br
/>
输出:
</strong>
"/"
<strong><br
/>
解释:
</strong>
从根目录向上一级是不可行的,因为根目录是你可以到达的最高级。
</pre><p><strong>
示例 3:
</strong></p><pre><strong>
输入:
</strong>
path = "/home//foo/"
<strong><br
/>
输出:
</strong>
"/home/foo"
<strong><br
/>
解释:
</strong>
在规范路径中,多个连续斜杠需要用一个斜杠替换。
</pre><p><strong>
示例 4:
</strong></p><pre><strong>
输入:
</strong>
path = "/a/./b/../../c/"
<strong><br
/>
输出:
</strong>
"/c"
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
1
<
=
path.length
<=
3000</
code
></li>
<li><code>
path
</code>
由英文字母,数字,
<code>
'.'
</code>
,
<code>
'/'
</code>
或
<code>
'_'
</code>
组成。
</li>
<li><code>
path
</code>
是一个有效的 Unix 风格绝对路径。
</li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -23,6 +27,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -106,7 +111,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -144,6 +151,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -189,6 +197,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/4.leetcode-栈与队列/83.柱状图中最大的矩形/solution.md
浏览文件 @
ceaae444
# 柱状图中最大的矩形
<p>给定 <em>n</em> 个非负整数,用来表示柱状图中各个柱子的高度。每个柱子彼此相邻,且宽度为 1 。</p><p>求在该柱状图中,能够勾勒出来的矩形的最大面积。</p><p> </p><p><img src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0084.Largest%20Rectangle%20in%20Histogram/images/histogram.png"></p><p><small>以上是柱状图的示例,其中每个柱子的宽度为 1,给定的高度为 <code>[2,1,5,6,2,3]</code>。</small></p><p> </p><p><img src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0084.Largest%20Rectangle%20in%20Histogram/images/histogram_area.png"></p><p><small>图中阴影部分为所能勾勒出的最大矩形面积,其面积为 <code>10</code> 个单位。</small></p><p> </p><p><strong>示例:</strong></p><pre><strong>输入:</strong> [2,1,5,6,2,3]<strong><br />输出:</strong> 10</pre>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -22,6 +26,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -51,7 +56,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -83,6 +90,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -121,6 +129,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/5.leetcode-排序算法/163.最大间距/solution.md
浏览文件 @
ceaae444
# 最大间距
<p>
给定一个无序的数组,找出数组在排序之后,相邻元素之间最大的差值。
</p>
<p>
如果数组元素个数小于 2,则返回 0。
</p>
...
...
@@ -25,12 +26,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -44,6 +48,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -65,7 +70,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -122,6 +129,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -163,6 +171,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/5.leetcode-排序算法/273.H 指数/solution.md
浏览文件 @
ceaae444
# H 指数
<p>
给你一个整数数组
<code>
citations
</code>
,其中
<code>
citations[i]
</code>
表示研究者的第
<code>
i
</code>
篇论文被引用的次数。计算并返回该研究者的
<strong><code>
h
</code><em>
</em>
指数
</strong>
。
</p>
<p><a
href=
"https://baike.baidu.com/item/h-index/3991452?fr=aladdin"
target=
"_blank"
>
h 指数的定义
</a>
:h 代表“高引用次数”(high citations),一名科研人员的 h 指数是指他(她)的 (
<code>
n
</code>
篇论文中)
<strong>
总共
</strong>
有
<code>
h
</code>
篇论文分别被引用了
<strong>
至少
</strong>
<code>
h
</code>
次。且其余的
<em><code>
n - h
</code>
</em>
篇论文每篇被引用次数
<strong>
不超过
</strong><em><code>
h
</code>
</em>
次。
</p>
...
...
@@ -37,12 +38,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -56,6 +60,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -84,7 +89,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -107,6 +114,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -137,6 +145,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/5.leetcode-排序算法/314.计算右侧小于当前元素的个数/solution.md
浏览文件 @
ceaae444
# 计算右侧小于当前元素的个数
<p>
给你
`一个整数数组 <code>nums</code><em> </em>,按要求返回一个新数组 <code>counts</code><em> </em>。数组 <code>counts</code> 有该性质: <code>counts[i]</code> 的值是 <code>nums[i]</code> 右侧小于 <code>nums[i]</code> 的元素的数量。</p>
<p> </p>
...
...
@@ -41,12 +42,15 @@
<p>以下错误的选项是?</p>
## aop
### before
```cpp
#include <bits/stdc++.h>
using namespace std;
```
### after
```cpp
int main()
{
...
...
@@ -61,6 +65,7 @@ int main()
```
## 答案
```cpp
class Solution
{
...
...
@@ -123,7 +128,9 @@ public:
```
## 选项
### A
```cpp
class Solution
{
...
...
@@ -183,6 +190,7 @@ public:
```
### B
```cpp
struct BSTNode
{
...
...
@@ -241,6 +249,7 @@ public:
```
### C
```cpp
class Solution
{
...
...
data/2.算法中阶/5.leetcode-排序算法/323.摆动排序 II/solution.md
浏览文件 @
ceaae444
# 摆动排序 II
<p>
给你一个整数数组
<code>
nums
</code>
,将它重新排列成
<code>
nums[0]
<
nums
[1]
>
nums[2]
<
nums
[3]...</
code
>
的顺序。
</p>
<p>
你可以假设所有输入数组都可以得到满足题目要求的结果。
</p>
...
...
@@ -37,18 +38,22 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -72,7 +77,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -93,6 +100,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -125,6 +133,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/5.leetcode-排序算法/326.区间和的个数/solution.md
浏览文件 @
ceaae444
# 区间和的个数
<p>
给你一个整数数组
<code>
nums
</code>
以及两个整数
<code>
lower
</code>
和
<code>
upper
</code>
。求数组中,值位于范围
<code>
[lower, upper]
</code>
(包含
<code>
lower
</code>
和
<code>
upper
</code>
)之内的
<strong>
区间和的个数
</strong>
。
</p>
<p><strong>
区间和
</strong>
<code>
S(i, j)
</code>
表示在
<code>
nums
</code>
中,位置从
<code>
i
</code>
到
<code>
j
</code>
的元素之和,包含
<code>
i
</code>
和
<code>
j
</code>
(
<code>
i
</code>
≤
<code>
j
</code>
)。
</p>
...
...
@@ -33,12 +34,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -54,6 +58,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -112,7 +117,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -139,6 +146,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -165,6 +173,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/5.leetcode-排序算法/346.前 K 个高频元素/solution.md
浏览文件 @
ceaae444
# 前 K 个高频元素
<p>
给你一个整数数组
<code>
nums
</code>
和一个整数
<code>
k
</code>
,请你返回其中出现频率前
<code>
k
</code>
高的元素。你可以按
<strong>
任意顺序
</strong>
返回答案。
</p>
<p>
</p>
...
...
@@ -33,12 +34,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -54,6 +58,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -80,7 +85,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -122,6 +129,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -164,6 +172,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/5.leetcode-排序算法/353.俄罗斯套娃信封问题/solution.md
浏览文件 @
ceaae444
# 俄罗斯套娃信封问题
<p>
给你一个二维整数数组
<code>
envelopes
</code>
,其中
<code>
envelopes[i] = [w
<sub>
i
</sub>
, h
<sub>
i
</sub>
]
</code>
,表示第
<code>
i
</code>
个信封的宽度和高度。
</p>
<p>
当另一个信封的宽度和高度都比这个信封大的时候,这个信封就可以放进另一个信封里,如同俄罗斯套娃一样。
</p>
...
...
@@ -35,17 +36,21 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -90,7 +95,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -114,6 +121,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -182,6 +190,7 @@ public:
```
### C
```
cpp
bool
sortV
(
vector
<
int
>
&
a
,
vector
<
int
>
&
b
)
{
...
...
data/2.算法中阶/5.leetcode-排序算法/377.有序矩阵中第 K 小的元素/solution.md
浏览文件 @
ceaae444
# 有序矩阵中第 K 小的元素
<p>
给你一个
<code>
n x n
</code><em>
</em>
矩阵
<code>
matrix
</code>
,其中每行和每列元素均按升序排序,找到矩阵中第
<code>
k
</code>
小的元素。
<br
/>
请注意,它是
<strong>
排序后
</strong>
的第
<code>
k
</code>
小元素,而不是第
<code>
k
</code>
个
<strong>
不同
</strong>
的元素。
</p>
...
...
@@ -35,17 +36,21 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -88,7 +93,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -124,6 +131,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -155,6 +163,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/5.leetcode-排序算法/492.翻转对/solution.md
浏览文件 @
ceaae444
# 翻转对
<p>
给定一个数组
<code>
nums
</code>
,如果
<code>
i
<
j
</code>
且
<code>
nums[i]
>
2
*
nums[j]
</code>
我们就将
<code>
(i, j)
</code>
称作一个
<strong><em>
重要翻转对
</em></strong>
。
</p>
<p>
你需要返回给定数组中的重要翻转对的数量。
</p>
...
...
@@ -27,12 +28,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -46,6 +50,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -109,7 +114,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -164,6 +171,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -217,6 +225,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/5.leetcode-排序算法/911.排序数组/solution.md
浏览文件 @
ceaae444
# 排序数组
<p>
给你一个整数数组
<code>
nums
</code>
,请你将该数组升序排列。
</p>
<p>
</p>
...
...
@@ -29,12 +30,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -49,6 +53,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -99,7 +104,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -126,6 +133,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -161,6 +169,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
@@ -192,6 +201,7 @@ public:
```
### D
```
cpp
class
Solution
{
...
...
@@ -227,6 +237,7 @@ public:
```
### E
```
cpp
class
Solution
{
...
...
@@ -284,6 +295,7 @@ public:
### F
```
cpp
class
Solution
{
...
...
data/2.算法中阶/6.leetcode-双指针/10.盛最多水的容器/solution.md
浏览文件 @
ceaae444
# 盛最多水的容器
<p>给你 <code>n</code> 个非负整数 <code>a<sub>1</sub>,a<sub>2,</sub>...,a</code><sub><code>n</code>,</sub>每个数代表坐标中的一个点 <code>(i, a<sub>i</sub>)</code> 。在坐标内画 <code>n</code> 条垂直线,垂直线 <code>i</code> 的两个端点分别为 <code>(i, a<sub>i</sub>)</code> 和 <code>(i, 0)</code> 。找出其中的两条线,使得它们与 <code>x</code> 轴共同构成的容器可以容纳最多的水。</p><p><strong>说明:</strong>你不能倾斜容器。</p><p> </p><p><strong>示例 1:</strong></p><p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0011.Container%20With%20Most%20Water/images/question_11.jpg" style="height: 287px; width: 600px;" /></p><pre><strong>输入:</strong>[1,8,6,2,5,4,8,3,7]<strong><br />输出:</strong>49 <strong><br />解释:</strong>图中垂直线代表输入数组 [1,8,6,2,5,4,8,3,7]。在此情况下,容器能够容纳水(表示为蓝色部分)的最大值为 49。</pre><p><strong>示例 2:</strong></p><pre><strong>输入:</strong>height = [1,1]<strong><br />输出:</strong>1</pre><p><strong>示例 3:</strong></p><pre><strong>输入:</strong>height = [4,3,2,1,4]<strong><br />输出:</strong>16</pre><p><strong>示例 4:</strong></p><pre><strong>输入:</strong>height = [1,2,1]<strong><br />输出:</strong>2</pre><p> </p><p><strong>提示:</strong></p><ul> <li><code>n = height.length</code></li> <li><code>2 <= n <= 3 * 10<sup>4</sup></code></li> <li><code>0 <= height[i] <= 3 * 10<sup>4</sup></code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -25,6 +29,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -47,7 +52,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -73,6 +80,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -105,6 +113,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/6.leetcode-双指针/140.环形链表/solution.md
浏览文件 @
ceaae444
# 环形链表
<p>
给定一个链表,判断链表中是否有环。
</p>
<p>
如果链表中有某个节点,可以通过连续跟踪
<code>
next
</code>
指针再次到达,则链表中存在环。 为了表示给定链表中的环,我们使用整数
<code>
pos
</code>
来表示链表尾连接到链表中的位置(索引从 0 开始)。 如果
<code>
pos
</code>
是
<code>
-1
</code>
,则在该链表中没有环。
<strong>
注意:
<code>
pos
</code>
不作为参数进行传递
</strong>
,仅仅是为了标识链表的实际情况。
</p>
...
...
@@ -53,7 +54,9 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -66,11 +69,13 @@ struct ListNode
};
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -94,7 +99,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -115,6 +122,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -144,6 +152,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/6.leetcode-双指针/141.环形链表 II/solution.md
浏览文件 @
ceaae444
# 环形链表 II
<p>
给定一个链表,返回链表开始入环的第一个节点。 如果链表无环,则返回
<code>
null
</code>
。
</p>
<p>
为了表示给定链表中的环,我们使用整数
<code>
pos
</code>
来表示链表尾连接到链表中的位置(索引从 0 开始)。 如果
<code>
pos
</code>
是
<code>
-1
</code>
,则在该链表中没有环。
<strong>
注意,
<code>
pos
</code>
仅仅是用于标识环的情况,并不会作为参数传递到函数中。
</strong></p>
...
...
@@ -56,7 +57,9 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -69,11 +72,13 @@ struct ListNode
};
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -108,7 +113,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -131,6 +138,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -165,6 +173,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/6.leetcode-双指针/15.最接近的三数之和/solution.md
浏览文件 @
ceaae444
# 最接近的三数之和
<p>
给定一个包括
<em>
n
</em>
个整数的数组
<code>
nums
</code><em>
</em>
和 一个目标值
<code>
target
</code>
。找出
<code>
nums
</code><em>
</em>
中的三个整数,使得它们的和与
<code>
target
</code>
最接近。返回这三个数的和。假定每组输入只存在唯一答案。
</p><p>
</p><p><strong>
示例:
</strong></p><pre><strong>
输入:
</strong>
nums = [-1,2,1,-4], target = 1
<strong><br
/>
输出:
</strong>
2
<strong><br
/>
解释:
</strong>
与 target 最接近的和是 2 (-1 + 2 + 1 = 2) 。
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
3
<
= nums.length
<
= 10^3
</code></li>
<li><code>
-10^3
<
= nums[i]
<
= 10^3
</code></li>
<li><code>
-10^4
<
= target
<
= 10^4
</code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
...
...
@@ -13,6 +16,7 @@ using namespace std;
```
### after
```
cpp
int
main
()
{
...
...
@@ -29,6 +33,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -70,7 +75,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -99,6 +106,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -131,6 +139,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/6.leetcode-双指针/25.删除有序数组中的重复项/solution.md
浏览文件 @
ceaae444
# 删除有序数组中的重复项
<div
class=
"notranslate"
>
<p>
给你一个有序数组
<code>
nums
</code>
,请你
<strong><a
href=
"http://baike.baidu.com/item/%E5%8E%9F%E5%9C%B0%E7%AE%97%E6%B3%95"
>
原地
</a></strong>
删除重复出现的元素,使每个元素
<strong>
只出现一次
</strong>
,返回删除后数组的新长度。
</p>
...
...
@@ -56,12 +57,15 @@ for (int i = 0; i < len; i++) {
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -82,6 +86,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -105,7 +110,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -134,6 +141,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -156,6 +164,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/6.leetcode-双指针/26.移除元素/solution.md
浏览文件 @
ceaae444
# 移除元素
<div
class=
"notranslate"
>
<p>
给你一个数组
<code>
nums
</code><em>
</em>
和一个值
<code>
val
</code>
,你需要
<strong>
<a
href="https://baike.baidu.com/item/%E5%8E%9F%E5%9C%B0%E7%AE%97%E6%B3%95">原地
</a></strong>
...
...
@@ -58,12 +59,15 @@ for (int i = 0; i < len; i++) {
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -77,6 +81,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -97,7 +102,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -119,6 +126,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -143,6 +151,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/6.leetcode-双指针/30.下一个排列/solution.md
浏览文件 @
ceaae444
# 下一个排列
<p>
实现获取
<strong>
下一个排列
</strong>
的函数,算法需要将给定数字序列重新排列成字典序中下一个更大的排列。
</p><p>
如果不存在下一个更大的排列,则将数字重新排列成最小的排列(即升序排列)。
</p><p>
必须
<strong><a
href=
"https://baike.baidu.com/item/%E5%8E%9F%E5%9C%B0%E7%AE%97%E6%B3%95"
target=
"_blank"
>
原地
</a></strong>
修改,只允许使用额外常数空间。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
nums = [1,2,3]
<strong><br
/>
输出:
</strong>
[1,3,2]
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
nums = [3,2,1]
<strong><br
/>
输出:
</strong>
[1,2,3]
</pre><p><strong>
示例 3:
</strong></p><pre><strong>
输入:
</strong>
nums = [1,1,5]
<strong><br
/>
输出:
</strong>
[1,5,1]
</pre><p><strong>
示例 4:
</strong></p><pre><strong>
输入:
</strong>
nums = [1]
<strong><br
/>
输出:
</strong>
[1]
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
1
<
=
nums.length
<=
100</
code
></li>
<li><code>
0
<
=
nums
[
i
]
<=
100</
code
></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -59,7 +64,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -90,6 +97,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -124,6 +132,7 @@ public:
```
### C
```
cpp
void
reverse
(
vector
<
int
>
&
nums
,
int
begin
,
int
end
)
{
...
...
data/2.算法中阶/6.leetcode-双指针/60.旋转链表/solution.md
浏览文件 @
ceaae444
# 旋转链表
<p>给你一个链表的头节点 <code>head</code> ,旋转链表,将链表每个节点向右移动 <code>k</code><em> </em>个位置。</p><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0061.Rotate%20List/images/rotate1.jpg" style="width: 600px; height: 254px;" /><pre><strong>输入:</strong>head = [1,2,3,4,5], k = 2<strong><br />输出:</strong>[4,5,1,2,3]</pre><p><strong>示例 2:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0061.Rotate%20List/images/roate2.jpg" style="width: 472px; height: 542px;" /><pre><strong>输入:</strong>head = [0,1,2], k = 4<strong><br />输出:</strong>[2,0,1]</pre><p> </p><p><strong>提示:</strong></p><ul> <li>链表中节点的数目在范围 <code>[0, 500]</code> 内</li> <li><code>-100 <= Node.val <= 100</code></li> <li><code>0 <= k <= 2 * 10<sup>9</sup></code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -16,11 +19,13 @@ struct ListNode
};
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -45,7 +50,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -79,6 +86,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -116,6 +124,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/6.leetcode-双指针/74.颜色分类/solution.md
浏览文件 @
ceaae444
# 颜色分类
<p>
给定一个包含红色、白色和蓝色,一共
<code>
n
</code><em>
</em>
个元素的数组,
<strong><a
href=
"https://baike.baidu.com/item/%E5%8E%9F%E5%9C%B0%E7%AE%97%E6%B3%95"
target=
"_blank"
>
原地
</a></strong>
对它们进行排序,使得相同颜色的元素相邻,并按照红色、白色、蓝色顺序排列。
</p><p>
此题中,我们使用整数
<code>
0
</code>
、
<code>
1
</code>
和
<code>
2
</code>
分别表示红色、白色和蓝色。
</p><ul></ul><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
nums = [2,0,2,1,1,0]
<strong><br
/>
输出:
</strong>
[0,0,1,1,2,2]
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
nums = [2,0,1]
<strong><br
/>
输出:
</strong>
[0,1,2]
</pre><p><strong>
示例 3:
</strong></p><pre><strong>
输入:
</strong>
nums = [0]
<strong><br
/>
输出:
</strong>
[0]
</pre><p><strong>
示例 4:
</strong></p><pre><strong>
输入:
</strong>
nums = [1]
<strong><br
/>
输出:
</strong>
[1]
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
n == nums.length
</code></li>
<li><code>
1
<
=
n
<=
300</
code
></li>
<li><code>
nums[i]
</code>
为
<code>
0
</code>
、
<code>
1
</code>
或
<code>
2
</code></li></ul><p>
</p><p><strong>
进阶:
</strong></p><ul>
<li>
你可以不使用代码库中的排序函数来解决这道题吗?
</li>
<li>
你能想出一个仅使用常数空间的一趟扫描算法吗?
</li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -25,6 +29,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -56,7 +61,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -80,6 +87,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -111,6 +119,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/2.算法中阶/6.leetcode-双指针/87.合并两个有序数组/solution.md
浏览文件 @
ceaae444
# 合并两个有序数组
<p>
给你两个有序整数数组
<code>
nums1
</code><em>
</em>
和
<code>
nums2
</code>
,请你将
<code>
nums2
</code><em>
</em>
合并到
<code>
nums1
</code><em>
</em>
中
<em>
,
</em>
使
<code>
nums1
</code><em>
</em>
成为一个有序数组。
</p><p>
初始化
<code>
nums1
</code>
和
<code>
nums2
</code>
的元素数量分别为
<code>
m
</code>
和
<code>
n
</code><em>
</em>
。你可以假设
<code>
nums1
</code><em>
</em>
的空间大小等于
<code>
m + n
</code>
,这样它就有足够的空间保存来自
<code>
nums2
</code>
的元素。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
nums1 = [1,2,3,0,0,0], m = 3, nums2 = [2,5,6], n = 3
<strong><br
/>
输出:
</strong>
[1,2,2,3,5,6]
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
nums1 = [1], m = 1, nums2 = [], n = 0
<strong><br
/>
输出:
</strong>
[1]
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
nums1.length == m + n
</code></li>
<li><code>
nums2.length == n
</code></li>
<li><code>
0
<
=
m
,
n
<=
200</
code
></li>
<li><code>
1
<
=
m
+
n
<=
200</
code
></li>
<li><code>
-10
<sup>
9
</sup>
<
=
nums1
[
i
],
nums2
[
i
]
<=
10<
sup
>
9
</sup></code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -26,6 +30,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -52,7 +57,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -85,6 +92,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -104,6 +112,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/1.leetcode-树/123.二叉树中的最大路径和/solution.md
浏览文件 @
ceaae444
# 二叉树中的最大路径和
<p><strong>
路径
</strong>
被定义为一条从树中任意节点出发,沿父节点-子节点连接,达到任意节点的序列。同一个节点在一条路径序列中
<strong>
至多出现一次
</strong>
。该路径
<strong>
至少包含一个
</strong>
节点,且不一定经过根节点。
</p>
<p><strong>
路径和
</strong>
是路径中各节点值的总和。
</p>
...
...
@@ -34,7 +35,9 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -50,11 +53,13 @@ struct TreeNode
};
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -86,7 +91,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -115,6 +122,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -141,6 +149,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/1.leetcode-树/93.二叉树的中序遍历/solution.md
浏览文件 @
ceaae444
# 二叉树的中序遍历
<p>给定一个二叉树的根节点 <code>root</code> ,返回它的 <strong>中序</strong> 遍历。</p><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0094.Binary%20Tree%20Inorder%20Traversal/images/inorder_1.jpg" style="width: 202px; height: 324px;" /><pre><strong>输入:</strong>root = [1,null,2,3]<strong><br />输出:</strong>[1,3,2]</pre><p><strong>示例 2:</strong></p><pre><strong>输入:</strong>root = []<strong><br />输出:</strong>[]</pre><p><strong>示例 3:</strong></p><pre><strong>输入:</strong>root = [1]<strong><br />输出:</strong>[1]</pre><p><strong>示例 4:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0094.Binary%20Tree%20Inorder%20Traversal/images/inorder_5.jpg" style="width: 202px; height: 202px;" /><pre><strong>输入:</strong>root = [1,2]<strong><br />输出:</strong>[2,1]</pre><p><strong>示例 5:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0094.Binary%20Tree%20Inorder%20Traversal/images/inorder_4.jpg" style="width: 202px; height: 202px;" /><pre><strong>输入:</strong>root = [1,null,2]<strong><br />输出:</strong>[1,2]</pre><p> </p><p><strong>提示:</strong></p><ul> <li>树中节点数目在范围 <code>[0, 100]</code> 内</li> <li><code>-100 <= Node.val <= 100</code></li></ul><p> </p><p><strong>进阶:</strong> 递归算法很简单,你可以通过迭代算法完成吗?</p>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -19,11 +22,13 @@ struct TreeNode
};
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -48,7 +53,9 @@ private:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -80,6 +87,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -110,6 +118,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/1.leetcode-树/94.不同的二叉搜索树 II/solution.md
浏览文件 @
ceaae444
# 不同的二叉搜索树 II
<div
class=
"notranslate"
>
<p>
给你一个整数
<code>
n
</code>
,请你生成并返回所有由
<code>
n
</code>
个节点组成且节点值从
<code>
1
</code>
到
<code>
n
</code>
互不相同的不同
<strong>
二叉搜索树
</strong><em>
</em>
。可以按
<strong>
任意顺序
</strong>
返回答案。
...
...
@@ -34,7 +35,9 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -50,11 +53,13 @@ struct TreeNode
};
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -97,7 +102,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -145,6 +152,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -187,6 +195,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/1.leetcode-树/95.不同的二叉搜索树/solution.md
浏览文件 @
ceaae444
# 不同的二叉搜索树
<div
class=
"notranslate"
>
<p>
给你一个整数
<code>
n
</code>
,求恰由
<code>
n
</code>
个节点组成且节点值从
<code>
1
</code>
到
<code>
n
</code>
互不相同的
<strong>
二叉搜索树
</strong>
有多少种?返回满足题意的二叉搜索树的种数。
</p>
...
...
@@ -29,17 +30,21 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -71,7 +76,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -102,6 +109,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -126,6 +134,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/1.leetcode-树/97.验证二叉搜索树/solution.md
浏览文件 @
ceaae444
# 验证二叉搜索树
<div
class=
"notranslate"
>
<p>
给你一个二叉树的根节点
<code>
root
</code>
,判断其是否是一个有效的二叉搜索树。
</p>
...
...
@@ -37,7 +38,9 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -53,11 +56,13 @@ struct TreeNode
};
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -81,7 +86,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -104,6 +111,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -132,6 +140,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/1.leetcode-树/98.恢复二叉搜索树/solution.md
浏览文件 @
ceaae444
# 恢复二叉搜索树
<p>给你二叉搜索树的根节点 <code>root</code> ,该树中的两个节点被错误地交换。请在不改变其结构的情况下,恢复这棵树。</p><p><strong>进阶:</strong>使用 O(<em>n</em>) 空间复杂度的解法很容易实现。你能想出一个只使用常数空间的解决方案吗?</p><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0099.Recover%20Binary%20Search%20Tree/images/recover1.jpg" style="width: 422px; height: 302px;" /><pre><strong>输入:</strong>root = [1,3,null,null,2]<strong><br />输出:</strong>[3,1,null,null,2]<strong><br />解释:</strong>3 不能是 1 左孩子,因为 3 > 1 。交换 1 和 3 使二叉搜索树有效。</pre><p><strong>示例 2:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0099.Recover%20Binary%20Search%20Tree/images/recover2.jpg" style="width: 581px; height: 302px;" /><pre><strong>输入:</strong>root = [3,1,4,null,null,2]<strong><br />输出:</strong>[2,1,4,null,null,3]<strong><br />解释:</strong>2 不能在 3 的右子树中,因为 2 < 3 。交换 2 和 3 使二叉搜索树有效。</pre><p> </p><p><strong>提示:</strong></p><ul> <li>树上节点的数目在范围 <code>[2, 1000]</code> 内</li> <li><code>-2<sup>31</sup> <= Node.val <= 2<sup>31</sup> - 1</code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -19,11 +22,13 @@ struct TreeNode
};
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -64,7 +69,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -95,6 +102,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -156,6 +164,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/1.leetcode-树/99.相同的树/solution.md
浏览文件 @
ceaae444
# 相同的树
<p>给你两棵二叉树的根节点 <code>p</code> 和 <code>q</code> ,编写一个函数来检验这两棵树是否相同。</p><p>如果两个树在结构上相同,并且节点具有相同的值,则认为它们是相同的。</p><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0100.Same%20Tree/images/ex1.jpg" style="width: 622px; height: 182px;" /><pre><strong>输入:</strong>p = [1,2,3], q = [1,2,3]<strong><br />输出:</strong>true</pre><p><strong>示例 2:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0100.Same%20Tree/images/ex2.jpg" style="width: 382px; height: 182px;" /><pre><strong>输入:</strong>p = [1,2], q = [1,null,2]<strong><br />输出:</strong>false</pre><p><strong>示例 3:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0100.Same%20Tree/images/ex3.jpg" style="width: 622px; height: 182px;" /><pre><strong>输入:</strong>p = [1,2,1], q = [1,1,2]<strong><br />输出:</strong>false</pre><p> </p><p><strong>提示:</strong></p><ul> <li>两棵树上的节点数目都在范围 <code>[0, 100]</code> 内</li> <li><code>-10<sup>4</sup> <= Node.val <= 10<sup>4</sup></code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -20,17 +23,21 @@ struct TreeNode
```
### after
```
cpp
```
## 答案
```
cpp
都是错的
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -45,6 +52,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -73,6 +81,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/2.leetcode-哈希表/204.同构字符串/solution.md
浏览文件 @
ceaae444
# 同构字符串
<p>
给定两个字符串
<em><strong>
s
</strong></em>
和
<strong><em>
t
</em></strong>
,判断它们是否是同构的。
</p>
<p>
如果
<em><strong>
s
</strong></em>
中的字符可以按某种映射关系替换得到
<strong><em>
t
</em></strong>
,那么这两个字符串是同构的。
</p>
...
...
@@ -37,12 +38,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -59,6 +63,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -103,7 +108,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -123,6 +130,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -170,6 +178,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/2.leetcode-哈希表/29.串联所有单词的子串/solution.md
浏览文件 @
ceaae444
# 串联所有单词的子串
<p>
给定一个字符串
<strong>
s
</strong>
和一些长度相同的单词
<strong>
words。
</strong>
找出
<strong>
s
</strong>
中恰好可以由
<strong>
words
</strong>
中所有单词串联形成的子串的起始位置。
</p>
<p>
注意子串要与
<strong>
words
</strong>
中的单词完全匹配,中间不能有其他字符,但不需要考虑
<strong>
words
</strong>
中单词串联的顺序。
</p>
...
...
@@ -10,12 +11,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -32,6 +36,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -76,7 +81,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -116,6 +123,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -174,6 +182,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/2.leetcode-哈希表/35.有效的数独/solution.md
浏览文件 @
ceaae444
# 有效的数独
<p>
请你判断一个
<code>
9x9
</code>
的数独是否有效。只需要
<strong>
根据以下规则
</strong>
,验证已经填入的数字是否有效即可。
</p>
<ol>
<li>
数字
<code>
1-9
</code>
在每一行只能出现一次。
</li>
...
...
@@ -50,16 +51,20 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -93,7 +98,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -162,6 +169,7 @@ private:
```
### B
```
cpp
class
Solution
{
...
...
@@ -259,6 +267,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/2.leetcode-哈希表/40.缺失的第一个正数/solution.md
浏览文件 @
ceaae444
# 缺失的第一个正数
<p>
给你一个未排序的整数数组
<code>
nums
</code>
,请你找出其中没有出现的最小的正整数。
</p><p>
</p><p><strong>
进阶:
</strong>
你可以实现时间复杂度为
<code>
O(n)
</code>
并且只使用常数级别额外空间的解决方案吗?
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
nums = [1,2,0]
<strong><br
/>
输出:
</strong>
3
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
nums = [3,4,-1,1]
<strong><br
/>
输出:
</strong>
2
</pre><p><strong>
示例 3:
</strong></p><pre><strong>
输入:
</strong>
nums = [7,8,9,11,12]
<strong><br
/>
输出:
</strong>
1
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
0
<
=
nums.length
<=
300</
code
></li>
<li><code>
-2
<sup>
31
</sup>
<
=
nums
[
i
]
<=
2<
sup
>
31
</sup>
- 1
</code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -24,6 +28,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -49,7 +54,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -85,6 +92,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -113,6 +121,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/2.leetcode-哈希表/48.字母异位词分组/solution.md
浏览文件 @
ceaae444
# 字母异位词分组
<p>
给定一个字符串数组,将字母异位词组合在一起。字母异位词指字母相同,但排列不同的字符串。
</p>
<p><strong>
示例:
</strong></p>
<pre><strong>
输入:
</strong>
[eat
"
,
"
tea
"
,
"
tan
"
,
"
ate
"
,
"
nat
"
,
"
bat
"
]
<strong><br
/>
输出:
</strong>
[[ate
"
,
"
eat
"
,
"
tea
"
],[
"
nat
"
,
"
tan
"
],[
"
bat
"
]]
</pre>
...
...
@@ -10,12 +11,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -36,6 +40,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -64,7 +69,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -98,6 +105,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -128,6 +136,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/2.leetcode-哈希表/75.最小覆盖子串/solution.md
浏览文件 @
ceaae444
# 最小覆盖子串
<p>
给你一个字符串
<code>
s
</code>
、一个字符串
<code>
t
</code>
。返回
<code>
s
</code>
中涵盖
<code>
t
</code>
所有字符的最小子串。如果
<code>
s
</code>
中不存在涵盖
<code>
t
</code>
所有字符的子串,则返回空字符串
<code>
""
</code>
。
</p><p><strong>
注意:
</strong>
如果
<code>
s
</code>
中存在这样的子串,我们保证它是唯一的答案。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
s = "ADOBECODEBANC", t = "ABC"
<strong><br
/>
输出:
</strong>
"BANC"
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
s = "a", t = "a"
<strong><br
/>
输出:
</strong>
"a"
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
1
<
=
s.length
,
t.length
<=
10<
sup
>
5
</sup></code></li>
<li><code>
s
</code>
和
<code>
t
</code>
由英文字母组成
</li></ul><p>
</p><strong>
进阶:
</strong>
你能设计一个在
<code>
o(n)
</code>
时间内解决此问题的算法吗?
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -24,6 +28,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -57,7 +62,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -111,6 +118,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -145,6 +153,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/3.leetcode-图与搜索/132.克隆图/solution.md
浏览文件 @
ceaae444
# 克隆图
<p>
给你无向
<strong><a
href=
"https://baike.baidu.com/item/连通图/6460995?fr=aladdin"
target=
"_blank"
>
连通
</a>
</strong>
图中一个节点的引用,请你返回该图的
<a
href=
"https://baike.baidu.com/item/深拷贝/22785317?fr=aladdin"
target=
"_blank"
><strong>
深拷贝
</strong></a>
(克隆)。
</p>
<p>
图中的每个节点都包含它的值
<code>
val
</code>
(
<code>
int
</code>
) 和其邻居的列表(
<code>
list[Node]
</code>
)。
</p>
...
...
@@ -72,7 +73,9 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
...
...
@@ -100,11 +103,13 @@ public:
};
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -132,7 +137,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -174,6 +181,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -198,6 +206,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/3.leetcode-图与搜索/206.课程表/solution.md
浏览文件 @
ceaae444
# 课程表
<p>
你这个学期必须选修
<code>
numCourses
</code>
门课程,记为
<code>
0
</code>
到
<code>
numCourses - 1
</code>
。
</p>
<p>
在选修某些课程之前需要一些先修课程。 先修课程按数组
<code>
prerequisites
</code>
给出,其中
<code>
prerequisites[i] = [a
<sub>
i
</sub>
, b
<sub>
i
</sub>
]
</code>
,表示如果要学习课程
<code>
a
<sub>
i
</sub></code>
则
<strong>
必须
</strong>
先学习课程
<code>
b
<sub>
i
</sub></code><sub>
</sub>
。
</p>
...
...
@@ -40,17 +41,21 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -107,7 +112,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -150,6 +157,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -191,6 +199,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/3.leetcode-图与搜索/209.课程表 II/solution.md
浏览文件 @
ceaae444
# 课程表 II
<p>
现在你总共有
<code>
numCourses
</code>
门课需要选,记为
<code>
0
</code>
到
<code>
numCourses - 1
</code>
。给你一个数组
<code>
prerequisites
</code>
,其中
<code>
prerequisites[i] = [a
<sub>
i
</sub>
, b
<sub>
i
</sub>
]
</code>
,表示在选修课程
<code>
a
<sub>
i
</sub></code>
前
<strong>
必须
</strong>
先选修
<code>
b
<sub>
i
</sub></code>
。
</p>
<ul>
...
...
@@ -59,17 +60,21 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -124,7 +129,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -164,6 +171,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -234,6 +242,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/3.leetcode-图与搜索/328.矩阵中的最长递增路径/solution.md
浏览文件 @
ceaae444
# 矩阵中的最长递增路径
<p>
给定一个
<code>
m x n
</code>
整数矩阵
<code>
matrix
</code>
,找出其中
<strong>
最长递增路径
</strong>
的长度。
</p>
<p>
对于每个单元格,你可以往上,下,左,右四个方向移动。 你
<strong>
不能
</strong>
在
<strong>
对角线
</strong>
方向上移动或移动到
<strong>
边界外
</strong>
(即不允许环绕)。
</p>
...
...
@@ -41,17 +42,21 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -98,7 +103,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -138,6 +145,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -199,6 +207,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/3.leetcode-图与搜索/331.重新安排行程/solution.md
浏览文件 @
ceaae444
# 重新安排行程
<p>
给你一份航线列表
<code>
tickets
</code>
,其中
<code>
tickets[i] = [from
<sub>
i
</sub>
, to
<sub>
i
</sub>
]
</code>
表示飞机出发和降落的机场地点。请你对该行程进行重新规划排序。
</p>
<p>
所有这些机票都属于一个从
<code>
JFK
</code>
(肯尼迪国际机场)出发的先生,所以该行程必须从
<code>
JFK
</code>
开始。如果存在多种有效的行程,请你按字典排序返回最小的行程组合。
</p>
...
...
@@ -42,17 +43,21 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
unordered_map
<
int
,
string
>
rev
;
int
cmp
(
pair
<
int
,
int
>
x
,
pair
<
int
,
int
>
y
)
...
...
@@ -126,7 +131,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -180,6 +187,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -209,6 +217,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/3.leetcode-图与搜索/76.组合/solution.md
浏览文件 @
ceaae444
# 组合
<p>
给定两个整数
<em>
n
</em>
和
<em>
k
</em>
,返回 1 ...
<em>
n
</em>
中所有可能的
<em>
k
</em>
个数的组合。
</p>
<p><strong>
示例:
</strong></p>
<pre><strong>
输入:
</strong>
n = 4, k = 2
<strong><br
/>
输出:
</strong>
[[2,4],[3,4],[2,3],[1,2],[1,3],[1,4],]
</pre>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -31,6 +35,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -81,7 +86,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -111,6 +118,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -139,6 +147,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/3.leetcode-图与搜索/78.单词搜索/solution.md
浏览文件 @
ceaae444
# 单词搜索
<p>给定一个 <code>m x n</code> 二维字符网格 <code>board</code> 和一个字符串单词 <code>word</code> 。如果 <code>word</code> 存在于网格中,返回 <code>true</code> ;否则,返回 <code>false</code> 。</p><p>单词必须按照字母顺序,通过相邻的单元格内的字母构成,其中“相邻”单元格是那些水平相邻或垂直相邻的单元格。同一个单元格内的字母不允许被重复使用。</p><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0079.Word%20Search/images/word2.jpg" style="width: 322px; height: 242px;" /><pre><strong>输入:</strong>board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCCED"<strong><br />输出:</strong>true</pre><p><strong>示例 2:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0079.Word%20Search/images/word-1.jpg" style="width: 322px; height: 242px;" /><pre><strong>输入:</strong>board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "SEE"<strong><br />输出:</strong>true</pre><p><strong>示例 3:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0079.Word%20Search/images/word3.jpg" style="width: 322px; height: 242px;" /><pre><strong>输入:</strong>board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCB"<strong><br />输出:</strong>false</pre><p> </p><p><strong>提示:</strong></p><ul> <li><code>m == board.length</code></li> <li><code>n = board[i].length</code></li> <li><code>1 <= m, n <= 6</code></li> <li><code>1 <= word.length <= 15</code></li> <li><code>board</code> 和 <code>word</code> 仅由大小写英文字母组成</li></ul><p> </p><p><strong>进阶:</strong>你可以使用搜索剪枝的技术来优化解决方案,使其在 <code>board</code> 更大的情况下可以更快解决问题?</p>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -25,6 +29,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -66,7 +71,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -98,6 +105,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -145,6 +153,7 @@ private:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/4.leetcode-数学/11.整数转罗马数字/solution.md
浏览文件 @
ceaae444
# 整数转罗马数字
<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>
...
...
@@ -71,12 +72,15 @@ M 1000</pre>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -88,6 +92,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -113,7 +118,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -235,6 +242,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -258,6 +266,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/4.leetcode-数学/12.罗马数字转整数/solution.md
浏览文件 @
ceaae444
# 罗马数字转整数
<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>
...
...
@@ -71,12 +72,15 @@ M 1000</pre>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -88,6 +92,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -192,7 +197,9 @@ private:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -266,6 +273,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -298,6 +306,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/4.leetcode-数学/28.两数相除/solution.md
浏览文件 @
ceaae444
# 两数相除
<p>
给定两个整数,被除数
<code>
dividend
</code>
和除数
<code>
divisor
</code>
。将两数相除,要求不使用乘法、除法和 mod 运算符。
</p><p>
返回被除数
<code>
dividend
</code>
除以除数
<code>
divisor
</code>
得到的商。
</p><p>
整数除法的结果应当截去(
<code>
truncate
</code>
)其小数部分,例如:
<code>
truncate(8.345) = 8
</code>
以及
<code>
truncate(-2.7335) = -2
</code></p><p>
</p><p><strong>
示例
1:
</strong></p><pre><strong>
输入:
</strong>
dividend = 10, divisor = 3
<strong><br
/>
输出:
</strong>
3
<strong><br
/>
解释:
</strong>
10/3 = truncate(3.33333..) = truncate(3) = 3
</pre><p><strong>
示例
2:
</strong></p><pre><strong>
输入:
</strong>
dividend = 7, divisor = -3
<strong><br
/>
输出:
</strong>
-2
<strong><br
/>
解释:
</strong>
7/-3 = truncate(-2.33333..) = -2
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li>
被除数和除数均为 32 位有符号整数。
</li>
<li>
除数不为
0。
</li>
<li>
假设我们的环境只能存储 32 位有符号整数,其数值范围是 [
−
2
<sup>
31
</sup>
,
2
<sup>
31
</sup>
−
1]。本题中,如果除法结果溢出,则返回 2
<sup>
31
</sup>
−
1。
</li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -21,6 +25,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -51,7 +56,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -99,6 +106,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -130,6 +138,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/4.leetcode-数学/49.Pow(x, n)/solution.md
浏览文件 @
ceaae444
# Pow(x, n)
<p>
实现
<a
href=
"https://www.cplusplus.com/reference/valarray/pow/"
target=
"_blank"
>
pow(
<em>
x
</em>
,
<em>
n
</em>
)
</a>
,即计算 x 的 n 次幂函数(即,x
<sup><span
style=
"font-size:10.8333px"
>
n
</span></sup>
)。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
x = 2.00000, n = 10
<strong><br
/>
输出:
</strong>
1024.00000
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
x = 2.10000, n = 3
<strong><br
/>
输出:
</strong>
9.26100
</pre><p><strong>
示例 3:
</strong></p><pre><strong>
输入:
</strong>
x = 2.00000, n = -2
<strong><br
/>
输出:
</strong>
0.25000
<strong><br
/>
解释:
</strong>
2
<sup>
-2
</sup>
= 1/2
<sup>
2
</sup>
= 1/4 = 0.25
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
-100.0
<
x
<
100.0</
code
></li>
<li><code>
-2
<sup>
31
</sup>
<
=
n
<= 2<
sup
>
31
</sup>
-1
</code></li>
<li><code>
-10
<sup>
4
</sup>
<
=
x
<
sup
>
n
</sup>
<
=
10<
sup
>
4
</sup></code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -25,6 +29,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -48,7 +53,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -87,6 +94,7 @@ private:
```
### B
```
cpp
class
Solution
{
...
...
@@ -117,6 +125,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/4.leetcode-数学/59.排列序列/solution.md
浏览文件 @
ceaae444
# 排列序列
<p>
给出集合
<code>
[1,2,3,...,n]
</code>
,其所有元素共有
<code>
n!
</code>
种排列。
</p><p>
按大小顺序列出所有排列情况,并一一标记,当
<code>
n = 3
</code>
时, 所有排列如下:
</p><ol>
<li><code>
"123"
</code></li>
<li><code>
"132"
</code></li>
<li><code>
"213"
</code></li>
<li><code>
"231"
</code></li>
<li><code>
"312"
</code></li>
<li><code>
"321"
</code></li></ol><p>
给定
<code>
n
</code>
和
<code>
k
</code>
,返回第
<code>
k
</code>
个排列。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
n = 3, k = 3
<strong><br
/>
输出:
</strong>
"213"
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
n = 4, k = 9
<strong><br
/>
输出:
</strong>
"2314"
</pre><p><strong>
示例 3:
</strong></p><pre><strong>
输入:
</strong>
n = 3, k = 1
<strong><br
/>
输出:
</strong>
"123"
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
1
<
=
n
<=
9</
code
></li>
<li><code>
1
<
=
k
<=
n
!</
code
></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -24,6 +28,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -56,7 +61,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
...
...
@@ -92,6 +99,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -133,6 +141,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/4.leetcode-数学/6.整数反转/solution.md
浏览文件 @
ceaae444
# 整数反转
<p>
给你一个 32 位的有符号整数
<code>
x
</code>
,返回将
<code>
x
</code>
中的数字部分反转后的结果。
</p><p>
如果反转后整数超过 32 位的有符号整数的范围
<code>
[−2
<sup>
31
</sup>
, 2
<sup>
31
</sup>
− 1]
</code>
,就返回 0。
</p><strong>
假设环境不允许存储 64 位整数(有符号或无符号)。
</strong><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
x = 123
<strong><br
/>
输出:
</strong>
321
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
x = -123
<strong><br
/>
输出:
</strong>
-321
</pre><p><strong>
示例 3:
</strong></p><pre><strong>
输入:
</strong>
x = 120
<strong><br
/>
输出:
</strong>
21
</pre><p><strong>
示例 4:
</strong></p><pre><strong>
输入:
</strong>
x = 0
<strong><br
/>
输出:
</strong>
0
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
-2
<sup>
31
</sup>
<
=
x
<=
2<
sup
>
31
</sup>
- 1
</code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -25,6 +29,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -43,7 +48,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -77,6 +84,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -100,6 +108,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/4.leetcode-数学/65.加一/solution.md
浏览文件 @
ceaae444
# 加一
<p>
给定一个由
<strong>
整数
</strong>
组成的
<strong>
非空
</strong>
数组所表示的非负整数,在该数的基础上加一。
</p><p>
最高位数字存放在数组的首位, 数组中每个元素只存储
<strong>
单个
</strong>
数字。
</p><p>
你可以假设除了整数 0 之外,这个整数不会以零开头。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
digits = [1,2,3]
<strong><br
/>
输出:
</strong>
[1,2,4]
<strong><br
/>
解释:
</strong>
输入数组表示数字 123。
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
digits = [4,3,2,1]
<strong><br
/>
输出:
</strong>
[4,3,2,2]
<strong><br
/>
解释:
</strong>
输入数组表示数字 4321。
</pre><p><strong>
示例 3:
</strong></p><pre><strong>
输入:
</strong>
digits = [0]
<strong><br
/>
输出:
</strong>
[1]
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
1
<
=
digits.length
<=
100</
code
></li>
<li><code>
0
<
=
digits
[
i
]
<=
9</
code
></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -23,6 +27,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -48,7 +53,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -75,6 +82,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -102,6 +110,7 @@ public:
```
### C
```
cpp
class
Solution
...
...
data/3.算法高阶/4.leetcode-数学/66.二进制求和/solution.md
浏览文件 @
ceaae444
# 二进制求和
<p>
给你两个二进制字符串,返回它们的和(用二进制表示)。
</p><p>
输入为
<strong>
非空
</strong>
字符串且只包含数字
<code>
1
</code>
和
<code>
0
</code>
。
</p><p>
</p><p><strong>
示例
1:
</strong></p><pre><strong>
输入:
</strong>
a =
"
11
"
, b =
"
1
"
<strong><br
/>
输出:
</strong>
"
100
"
</pre><p><strong>
示例
2:
</strong></p><pre><strong>
输入:
</strong>
a =
"
1010
"
, b =
"
1011
"
<strong><br
/>
输出:
</strong>
"
10101
"
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li>
每个字符串仅由字符
<code>
'
0
'
</code>
或
<code>
'
1
'
</code>
组成。
</li>
<li><code>
1
<
= a.length, b.length
<
= 10^4
</code></li>
<li>
字符串如果不是
<code>
"
0
"
</code>
,就都不含前导零。
</li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -23,6 +27,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -48,7 +53,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -91,6 +98,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -142,6 +150,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/4.leetcode-数学/68.x 的平方根/solution.md
浏览文件 @
ceaae444
# x 的平方根
<p>
实现
<code>
int sqrt(int x)
</code>
函数。
</p>
<p>
计算并返回
<em>
x
</em>
的平方根,其中
<em>
x
</em>
是非负整数。
</p>
<p>
由于返回类型是整数,结果只保留整数的部分,小数部分将被舍去。
</p>
...
...
@@ -9,12 +10,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -29,6 +33,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -51,7 +56,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -73,6 +80,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -99,6 +107,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/4.leetcode-数学/8.回文数/solution.md
浏览文件 @
ceaae444
# 回文数
<p>
给你一个整数
<code>
x
</code>
,如果
<code>
x
</code>
是一个回文整数,返回
<code>
true
</code>
;否则,返回
<code>
false
</code>
。
</p><p>
回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。例如,
<code>
121
</code>
是回文,而
<code>
123
</code>
不是。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
x = 121
<strong><br
/>
输出:
</strong>
true
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
x = -121
<strong><br
/>
输出:
</strong>
false
<strong><br
/>
解释:
</strong>
从左向右读, 为 -121 。 从右向左读, 为 121- 。因此它不是一个回文数。
</pre><p><strong>
示例 3:
</strong></p><pre><strong>
输入:
</strong>
x = 10
<strong><br
/>
输出:
</strong>
false
<strong><br
/>
解释:
</strong>
从右向左读, 为 01 。因此它不是一个回文数。
</pre><p><strong>
示例 4:
</strong></p><pre><strong>
输入:
</strong>
x = -101
<strong><br
/>
输出:
</strong>
false
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
-2
<sup>
31
</sup>
<
=
x
<=
2<
sup
>
31
</sup>
- 1
</code></li></ul><p>
</p><p><strong>
进阶:
</strong>
你能不将整数转为字符串来解决这个问题吗?
</p>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -20,6 +24,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -38,7 +43,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
...
...
@@ -64,6 +71,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -84,6 +92,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/5.leetcode-设计/145.LRU 缓存机制/solution.md
浏览文件 @
ceaae444
# LRU 缓存机制
<div
class=
"title__3Vvk"
>
运用你所掌握的数据结构,设计和实现一个
<a
href=
"https://baike.baidu.com/item/LRU"
target=
"_blank"
>
LRU (最近最少使用) 缓存机制
</a>
。
</div>
<div
class=
"original__bRMd"
>
...
...
@@ -55,17 +56,21 @@ lRUCache.get(4); // 返回 4
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
class
LRUCache
{
...
...
@@ -110,7 +115,9 @@ private:
```
## 选项
### A
```
cpp
class
LRUCache
{
...
...
@@ -205,6 +212,7 @@ public:
```
### B
```
cpp
class
LRUCache
{
...
...
@@ -260,6 +268,7 @@ public:
```
### C
```
cpp
class
LRUCache
{
...
...
data/3.算法高阶/5.leetcode-设计/354.设计推特/solution.md
浏览文件 @
ceaae444
# 设计推特
<p>
设计一个简化版的推特(Twitter),可以让用户实现发送推文,关注/取消关注其他用户,能够看见关注人(包括自己)的最近
<code>
10
</code>
条推文。
</p>
<p>
实现
<code>
Twitter
</code>
类:
</p>
...
...
@@ -46,17 +47,21 @@ twitter.getNewsFeed(1); // 用户 1 获取推文应当返回一个列表,其
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
class
Twitter
{
...
...
@@ -159,7 +164,9 @@ private:
```
## 选项
### A
```
cpp
class
Twitter
{
...
...
@@ -223,6 +230,7 @@ public:
```
### B
```
cpp
class
Twitter
{
...
...
@@ -287,6 +295,7 @@ private:
```
### C
```
cpp
class
Twitter
{
...
...
data/3.算法高阶/5.leetcode-设计/379.O(1) 时间插入、删除和获取随机元素/solution.md
浏览文件 @
ceaae444
# O(1) 时间插入、删除和获取随机元素
<p>
实现
<code>
RandomizedSet
</code>
类:
</p>
<div
class=
"original__bRMd"
>
...
...
@@ -49,18 +50,22 @@ randomizedSet.getRandom(); // 由于 2 是集合中唯一的数字,getRandom
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
class
RandomizedSet
{
...
...
@@ -106,7 +111,9 @@ public:
```
## 选项
### A
```
cpp
class
RandomizedSet
{
...
...
@@ -161,6 +168,7 @@ private:
```
### B
```
cpp
class
RandomizedSet
{
...
...
@@ -205,6 +213,7 @@ public:
```
### C
```
cpp
class
RandomizedSet
{
...
...
data/3.算法高阶/5.leetcode-设计/380.O(1) 时间插入、删除和获取随机元素 - 允许重复/solution.md
浏览文件 @
ceaae444
# O(1) 时间插入、删除和获取随机元素 - 允许重复
<p>
设计一个支持在
<em>
平均
</em>
时间复杂度
<strong>
O(1)
</strong>
下
<strong>
,
</strong>
执行以下操作的数据结构。
</p>
<p><strong>
注意: 允许出现重复元素。
</strong></p>
...
...
@@ -36,17 +37,21 @@ collection.getRandom();
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
class
RandomizedCollection
{
...
...
@@ -114,7 +119,9 @@ private:
```
## 选项
### A
```
cpp
class
RandomizedSet
{
...
...
@@ -162,6 +169,7 @@ public:
```
### B
```
cpp
class
RandomizedCollection
{
...
...
@@ -214,6 +222,7 @@ public:
```
### C
```
cpp
class
RandomizedCollection
{
...
...
data/3.算法高阶/5.leetcode-设计/459.LFU 缓存/solution.md
浏览文件 @
ceaae444
# LFU 缓存
<p>
请你为
<a
href=
"https://baike.baidu.com/item/%E7%BC%93%E5%AD%98%E7%AE%97%E6%B3%95"
>
最不经常使用(LFU)
</a>
缓存算法设计并实现数据结构。
</p>
<p>
实现
<code>
LFUCache
</code>
类:
</p>
...
...
@@ -63,17 +64,21 @@ lFUCache.get(4); // 返回 4
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
```
## 答案
```
cpp
class
LFUCache
{
...
...
@@ -132,7 +137,9 @@ public:
```
## 选项
### A
```
cpp
class
Node
{
...
...
@@ -217,6 +224,7 @@ public:
```
### B
```
cpp
class
LFUCache
{
...
...
@@ -316,6 +324,7 @@ private:
```
### C
```
cpp
struct
Value
{
...
...
data/3.算法高阶/6.leetcode-动态规划/21.括号生成/solution.md
浏览文件 @
ceaae444
# 括号生成
<p>
数字
<code>
n
</code>
代表生成括号的对数,请你设计一个函数,用于能够生成所有可能的并且
<strong>
有效的
</strong>
括号组合。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
n = 3
<strong><br
/>
输出:
</strong>
["((()))","(()())","(())()","()(())","()()()"]
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
n = 1
<strong><br
/>
输出:
</strong>
["()"]
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
1
<
=
n
<=
8</
code
></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -25,6 +29,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -63,7 +68,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -96,6 +103,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -127,6 +135,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/6.leetcode-动态规划/4.最长回文子串/solution.md
浏览文件 @
ceaae444
# 最长回文子串
<p>
给你一个字符串
<code>
s
</code>
,找到
<code>
s
</code>
中最长的回文子串。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
s = "babad"
<strong><br
/>
输出:
</strong>
"bab"
<strong><br
/>
解释:
</strong>
"aba" 同样是符合题意的答案。
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
s = "cbbd"
<strong><br
/>
输出:
</strong>
"bb"
</pre><p><strong>
示例 3:
</strong></p><pre><strong>
输入:
</strong>
s = "a"
<strong><br
/>
输出:
</strong>
"a"
</pre><p><strong>
示例 4:
</strong></p><pre><strong>
输入:
</strong>
s = "ac"
<strong><br
/>
输出:
</strong>
"a"
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
1
<
=
s.length
<=
1000</
code
></li>
<li><code>
s
</code>
仅由数字和英文字母(大写和/或小写)组成
</li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -23,6 +27,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -66,7 +71,9 @@ private:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -108,6 +115,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -151,6 +159,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/6.leetcode-动态规划/43.通配符匹配/solution.md
浏览文件 @
ceaae444
# 通配符匹配
<p>
给定一个字符串
(
<code>
s
</code>
) 和一个字符模式
(
<code>
p
</code>
) ,实现一个支持
<code>
'
?
'
</code>
和
<code>
'
*
'
</code>
的通配符匹配。
</p><pre>
'
?
'
可以匹配任何单个字符。
'
*
'
可以匹配任意字符串(包括空字符串)。
</pre><p>
两个字符串
<strong>
完全匹配
</strong>
才算匹配成功。
</p><p><strong>
说明:
</strong></p><ul>
<li><code>
s
</code>
可能为空,且只包含从
<code>
a-z
</code>
的小写字母。
</li>
<li><code>
p
</code>
可能为空,且只包含从
<code>
a-z
</code>
的小写字母,以及字符
<code>
?
</code>
和
<code>
*
</code>
。
</li></ul><p><strong>
示例
1:
</strong></p><pre><strong>
输入:
</strong>
s =
"
aa
"
p =
"
a
"
<strong><br
/>
输出:
</strong>
false
<strong><br
/>
解释:
</strong>
"
a
"
无法匹配
"
aa
"
整个字符串。
</pre><p><strong>
示例
2:
</strong></p><pre><strong>
输入:
</strong>
s =
"
aa
"
p =
"
*
"
<strong><br
/>
输出:
</strong>
true
<strong><br
/>
解释:
</strong>
'
*
'
可以匹配任意字符串。
</pre><p><strong>
示例
3:
</strong></p><pre><strong>
输入:
</strong>
s =
"
cb
"
p =
"
?a
"
<strong><br
/>
输出:
</strong>
false
<strong><br
/>
解释:
</strong>
'
?
'
可以匹配
'
c
'
, 但第二个
'
a
'
无法匹配
'
b
'
。
</pre><p><strong>
示例
4:
</strong></p><pre><strong>
输入:
</strong>
s =
"
adceb
"
p =
"
*a*b
"
<strong><br
/>
输出:
</strong>
true
<strong><br
/>
解释:
</strong>
第一个
'
*
'
可以匹配空字符串, 第二个
'
*
'
可以匹配字符串
"
dce
"
.
</pre><p><strong>
示例
5:
</strong></p><pre><strong>
输入:
</strong>
s =
"
acdcb
"
p =
"
a*c?b
"
<strong><br
/>
输出:
</strong>
false
</pre>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -24,6 +28,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -77,7 +82,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -125,6 +132,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -157,6 +165,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/6.leetcode-动态规划/52.最大子序和/solution.md
浏览文件 @
ceaae444
# 最大子序和
<p>
给定一个整数数组
<code>
nums
</code>
,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
nums = [-2,1,-3,4,-1,2,1,-5,4]
<strong><br
/>
输出:
</strong>
6
<strong><br
/>
解释:
</strong>
连续子数组 [4,-1,2,1] 的和最大,为 6 。
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
nums = [1]
<strong><br
/>
输出:
</strong>
1
</pre><p><strong>
示例 3:
</strong></p><pre><strong>
输入:
</strong>
nums = [0]
<strong><br
/>
输出:
</strong>
0
</pre><p><strong>
示例 4:
</strong></p><pre><strong>
输入:
</strong>
nums = [-1]
<strong><br
/>
输出:
</strong>
-1
</pre><p><strong>
示例 5:
</strong></p><pre><strong>
输入:
</strong>
nums = [-100000]
<strong><br
/>
输出:
</strong>
-100000
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
1
<
=
nums.length
<=
3
*
10<
sup
>
4
</sup></code></li>
<li><code>
-10
<sup>
5
</sup>
<
=
nums
[
i
]
<=
10<
sup
>
5
</sup></code></li></ul><p>
</p><p><strong>
进阶:
</strong>
如果你已经实现复杂度为
<code>
O(n)
</code>
的解法,尝试使用更为精妙的
<strong>
分治法
</strong>
求解。
</p>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -23,6 +27,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -43,7 +48,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -69,6 +76,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -107,6 +115,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/6.leetcode-动态规划/61.不同路径/solution.md
浏览文件 @
ceaae444
# 不同路径
<p>
一个机器人位于一个
<code>
m x n
</code><em>
</em>
网格的左上角 (起始点在下图中标记为 “Start” )。
</p>
<p>
机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为 “Finish” )。
</p>
<p>
问总共有多少条不同的路径?
</p>
...
...
@@ -21,12 +22,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -42,6 +46,7 @@ int main()
```
## 答案
```
cpp
class
Solution
...
...
@@ -63,7 +68,9 @@ public:
```
## 选项
### A
```
cpp
typedef
vector
<
int
>
BigInt
;
class
Solution
...
...
@@ -133,6 +140,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -167,6 +175,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/6.leetcode-动态规划/62.不同路径 II/solution.md
浏览文件 @
ceaae444
# 不同路径 II
<p>
一个机器人位于一个
<em>
m x n
</em>
网格的左上角 (起始点在下图中标记为“Start” )。
</p>
<p>
机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。
</p>
<p>
现在考虑网格中有障碍物。那么从左上角到右下角将会有多少条不同的路径?
</p>
...
...
@@ -25,12 +26,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -47,6 +51,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -74,7 +79,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -107,6 +114,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -144,6 +152,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/6.leetcode-动态规划/63.最小路径和/solution.md
浏览文件 @
ceaae444
# 最小路径和
<p>给定一个包含非负整数的 <code><em>m</em> x <em>n</em></code> 网格 <code>grid</code> ,请找出一条从左上角到右下角的路径,使得路径上的数字总和为最小。</p><p><strong>说明:</strong>每次只能向下或者向右移动一步。</p><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0064.Minimum%20Path%20Sum/images/minpath.jpg" style="width: 242px; height: 242px;" /><pre><strong>输入:</strong>grid = [[1,3,1],[1,5,1],[4,2,1]]<strong><br />输出:</strong>7<strong><br />解释:</strong>因为路径 1→3→1→1→1 的总和最小。</pre><p><strong>示例 2:</strong></p><pre><strong>输入:</strong>grid = [[1,2,3],[4,5,6]]<strong><br />输出:</strong>12</pre><p> </p><p><strong>提示:</strong></p><ul> <li><code>m == grid.length</code></li> <li><code>n == grid[i].length</code></li> <li><code>1 <= m, n <= 200</code></li> <li><code>0 <= grid[i][j] <= 100</code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -24,6 +28,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -67,7 +72,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -95,6 +102,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -125,6 +133,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/6.leetcode-动态规划/69.爬楼梯/solution.md
浏览文件 @
ceaae444
# 爬楼梯
<p>
假设你正在爬楼梯。需要
<em>
n
</em>
阶你才能到达楼顶。
</p><p>
每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢?
</p><p><strong>
注意:
</strong>
给定
<em>
n
</em>
是一个正整数。
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
2
<strong><br
/>
输出:
</strong>
2
<strong><br
/>
解释:
</strong>
有两种方法可以爬到楼顶。1. 1 阶 + 1 阶2. 2 阶
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
3
<strong><br
/>
输出:
</strong>
3
<strong><br
/>
解释:
</strong>
有三种方法可以爬到楼顶。1. 1 阶 + 1 阶 + 1 阶2. 1 阶 + 2 阶3. 2 阶 + 1 阶
</pre>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -24,6 +28,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -38,7 +43,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -62,6 +69,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -79,6 +87,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/6.leetcode-动态规划/71.编辑距离/solution.md
浏览文件 @
ceaae444
# 编辑距离
<p>
给你两个单词
<code>
word1
</code>
和
<code>
word2
</code>
,请你计算出将
<code>
word1
</code>
转换成
<code>
word2
</code><em>
</em>
所使用的最少操作数 。
</p><p>
你可以对一个单词进行如下三种操作:
</p><ul>
<li>
插入一个字符
</li>
<li>
删除一个字符
</li>
<li>
替换一个字符
</li></ul><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
word1 = "horse", word2 = "ros"
<strong><br
/>
输出:
</strong>
3
<strong><br
/>
解释:
</strong>
horse -> rorse (将 'h' 替换为 'r')rorse -> rose (删除 'r')rose -> ros (删除 'e')
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
word1 = "intention", word2 = "execution"
<strong><br
/>
输出:
</strong>
5
<strong><br
/>
解释:
</strong>
intention -> inention (删除 't')inention -> enention (将 'i' 替换为 'e')enention -> exention (将 'n' 替换为 'x')exention -> exection (将 'n' 替换为 'c')exection -> execution (插入 'u')
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
0
<
=
word1.length
,
word2.length
<=
500</
code
></li>
<li><code>
word1
</code>
和
<code>
word2
</code>
由小写英文字母组成
</li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -25,6 +29,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -56,7 +61,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -113,6 +120,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -157,6 +165,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/6.leetcode-动态规划/84.最大矩形/solution.md
浏览文件 @
ceaae444
# 最大矩形
<p>给定一个仅包含 <code>0</code> 和 <code>1</code> 、大小为 <code>rows x cols</code> 的二维二进制矩阵,找出只包含 <code>1</code> 的最大矩形,并返回其面积。</p><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0085.Maximal%20Rectangle/images/maximal.jpg" style="width: 402px; height: 322px;" /><pre><strong>输入:</strong>matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]]<strong><br />输出:</strong>6<strong><br />解释:</strong>最大矩形如上图所示。</pre><p><strong>示例 2:</strong></p><pre><strong>输入:</strong>matrix = []<strong><br />输出:</strong>0</pre><p><strong>示例 3:</strong></p><pre><strong>输入:</strong>matrix = [["0"]]<strong><br />输出:</strong>0</pre><p><strong>示例 4:</strong></p><pre><strong>输入:</strong>matrix = [["1"]]<strong><br />输出:</strong>1</pre><p><strong>示例 5:</strong></p><pre><strong>输入:</strong>matrix = [["0","0"]]<strong><br />输出:</strong>0</pre><p> </p><p><strong>提示:</strong></p><ul> <li><code>rows == matrix.length</code></li> <li><code>cols == matrix[0].length</code></li> <li><code>0 <= row, cols <= 200</code></li> <li><code>matrix[i][j]</code> 为 <code>'0'</code> 或 <code>'1'</code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -25,6 +29,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -70,7 +75,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -116,6 +123,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -189,6 +197,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/6.leetcode-动态规划/86.扰乱字符串/solution.md
浏览文件 @
ceaae444
# 扰乱字符串
<div
class=
"notranslate"
>
使用下面描述的算法可以扰乱字符串
<code>
s
</code>
得到字符串
<code>
t
</code>
:
<ol>
<li>
如果字符串的长度为 1 ,算法停止
</li>
...
...
@@ -61,12 +62,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -81,6 +85,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -123,7 +128,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -171,6 +178,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -208,6 +216,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/6.leetcode-动态规划/9.正则表达式匹配/solution.md
浏览文件 @
ceaae444
# 正则表达式匹配
<p>
给你一个字符串
<code>
s
</code>
和一个字符规律
<code>
p
</code>
,请你来实现一个支持
<code>
'.'
</code>
和
<code>
'
*'</code> 的正则表达式匹配。</p><ul> <li><code>'.'</code> 匹配任意单个字符</li> <li><code>'*
'
</code>
匹配零个或多个前面的那一个元素
</li></ul><p>
所谓匹配,是要涵盖
<strong>
整个
</strong>
字符串
<code>
s
</code>
的,而不是部分字符串。
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
s = "aa" p = "a"
<strong><br
/>
输出:
</strong>
false
<strong><br
/>
解释:
</strong>
"a" 无法匹配 "aa" 整个字符串。
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
s = "aa" p = "a
*"<strong><br />输出:</strong>true<strong><br />解释:</strong>因为 '*
' 代表可以匹配零个或多个前面的那一个元素, 在这里前面的元素就是 'a'。因此,字符串 "aa" 可被视为 'a' 重复了一次。
</pre><p><strong>
示例 3:
</strong></p><pre><strong>
输入:
</strong>
s = "ab" p = ".
*"<strong><br />输出:</strong>true<strong><br />解释:</strong>".*
" 表示可匹配零个或多个('
*')任意字符('.')。</pre><p><strong>示例 4:</strong></p><pre><strong>输入:</strong>s = "aab" p = "c*
a
*b"<strong><br />输出:</strong>true<strong><br />解释:</strong>因为 '*
' 表示零个或多个,这里 'c' 为 0 个, 'a' 被重复一次。因此可以匹配字符串 "aab"。
</pre><p><strong>
示例 5:
</strong></p><pre><strong>
输入:
</strong>
s = "mississippi" p = "mis
*is*
p
*."<strong><br />输出:</strong>false</pre><p> </p><p><strong>提示:</strong></p><ul> <li><code>0 <= s.length <= 20</code></li> <li><code>0 <= p.length <= 30</code></li> <li><code>s</code> 可能为空,且只包含从 <code>a-z</code> 的小写字母。</li> <li><code>p</code> 可能为空,且只包含从 <code>a-z</code> 的小写字母,以及字符 <code>.</code> 和 <code>*
</code>
。
</li>
<li>
保证每次出现字符
<code>
*
</code>
时,前面都匹配到有效的字符
</li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -21,6 +25,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -69,7 +74,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -116,6 +123,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -155,6 +163,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/6.leetcode-动态规划/90.解码方法/solution.md
浏览文件 @
ceaae444
# 解码方法
<p>
一条包含字母
<code>
A-Z
</code>
的消息通过以下映射进行了
<strong>
编码
</strong>
:
</p>
<pre>
'A' -> 1'B' -> 2...'Z' -> 26
</pre>
<p>
要
<strong>
解码
</strong>
已编码的消息,所有数字必须基于上述映射的方法,反向映射回字母(可能有多种方法)。例如,
<code>
"11106"
</code>
可以映射为:
</p>
...
...
@@ -29,12 +30,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -48,6 +52,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -70,7 +75,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -119,6 +126,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -161,6 +169,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/7.leetcode-回溯算法/16.电话号码的字母组合/solution.md
浏览文件 @
ceaae444
# 电话号码的字母组合
<p>给定一个仅包含数字 <code>2-9</code> 的字符串,返回所有它能表示的字母组合。答案可以按 <strong>任意顺序</strong> 返回。</p><p>给出数字到字母的映射如下(与电话按键相同)。注意 1 不对应任何字母。</p><p><img src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0017.Letter%20Combinations%20of%20a%20Phone%20Number/images/17_telephone_keypad.png" style="width: 200px;" /></p><p> </p><p><strong>示例 1:</strong></p><pre><strong>输入:</strong>digits = "23"<strong><br />输出:</strong>["ad","ae","af","bd","be","bf","cd","ce","cf"]</pre><p><strong>示例 2:</strong></p><pre><strong>输入:</strong>digits = ""<strong><br />输出:</strong>[]</pre><p><strong>示例 3:</strong></p><pre><strong>输入:</strong>digits = "2"<strong><br />输出:</strong>["a","b","c"]</pre><p> </p><p><strong>提示:</strong></p><ul> <li><code>0 <= digits.length <= 4</code></li> <li><code>digits[i]</code> 是范围 <code>['2', '9']</code> 的一个数字。</li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -23,6 +27,7 @@ int main()
```
## 答案
```
cpp
string
letterMap
[
10
]
=
{
" "
,
" "
,
"abc"
,
"def"
,
"ghi"
,
"jkl"
,
"mno"
,
"pqrs"
,
"tuv"
,
"wxyz"
};
class
Solution
...
...
@@ -56,7 +61,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -144,6 +151,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -172,6 +180,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/7.leetcode-回溯算法/36.解数独/solution.md
浏览文件 @
ceaae444
# 解数独
<p>
编写一个程序,通过填充空格来解决数独问题。
</p>
<p>
数独的解法需
<strong>
遵循如下规则
</strong>
:
</p>
<ol>
...
...
@@ -53,16 +54,20 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
```
### after
```
cpp
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -131,7 +136,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -209,6 +216,7 @@ private:
```
### B
```
cpp
class
Solution
{
...
...
@@ -277,6 +285,7 @@ private:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/7.leetcode-回溯算法/38.组合总和/solution.md
浏览文件 @
ceaae444
# 组合总和
<p>
给定一个
<strong>
无重复元素
</strong>
的数组
<code>
candidates
</code>
和一个目标数
<code>
target
</code>
,找出
<code>
candidates
</code>
中所有可以使数字和为
<code>
target
</code>
的组合。
</p>
<p><code>
candidates
</code>
中的数字可以无限制重复被选取。
</p>
...
...
@@ -22,12 +23,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -49,6 +53,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -88,7 +93,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
...
...
@@ -127,6 +134,7 @@ private:
```
### B
```
cpp
class
Solution
{
...
...
@@ -168,6 +176,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/7.leetcode-回溯算法/39.组合总和 II/solution.md
浏览文件 @
ceaae444
# 组合总和 II
<p>
给定一个数组
<code>
candidates
</code>
和一个目标数
<code>
target
</code>
,找出
<code>
candidates
</code>
中所有可以使数字和为
<code>
target
</code>
的组合。
</p>
<p><code>
candidates
</code>
中的每个数字在每个组合中只能使用一次。
</p>
...
...
@@ -14,12 +15,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -41,6 +45,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -78,7 +83,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -122,6 +129,7 @@ private:
```
### B
```
cpp
class
Solution
{
...
...
@@ -170,6 +178,7 @@ private:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/7.leetcode-回溯算法/45.全排列/solution.md
浏览文件 @
ceaae444
# 全排列
<p>
给定一个
<strong>
没有重复
</strong>
数字的序列,返回其所有可能的全排列。
</p><p><strong>
示例:
</strong></p><pre><strong>
输入:
</strong>
[1,2,3]
<strong><br
/>
输出:
</strong>
[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]
</pre>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
...
...
@@ -30,6 +34,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -64,7 +69,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -104,6 +111,7 @@ private:
```
### B
```
cpp
class
Solution
{
...
...
@@ -137,6 +145,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/7.leetcode-回溯算法/46.全排列 II/solution.md
浏览文件 @
ceaae444
# 全排列 II
<p>
给定一个可包含重复数字的序列
<code>
nums
</code>
,
<strong>
按任意顺序
</strong>
返回所有不重复的全排列。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
nums = [1,1,2]
<strong><br
/>
输出:
</strong>
[[1,1,2], [1,2,1], [2,1,1]]
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
nums = [1,2,3]
<strong><br
/>
输出:
</strong>
[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
1
<
=
nums.length
<=
8</
code
></li>
<li><code>
-10
<
=
nums
[
i
]
<=
10</
code
></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -29,6 +33,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -70,7 +75,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -112,6 +119,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -156,6 +164,7 @@ private:
```
### C
```
cpp
class
Solution
...
...
data/3.算法高阶/7.leetcode-回溯算法/50.N 皇后/solution.md
浏览文件 @
ceaae444
# N 皇后
<p><strong>n 皇后问题</strong> 研究的是如何将 <code>n</code> 个皇后放置在 <code>n×n</code> 的棋盘上,并且使皇后彼此之间不能相互攻击。</p><p>给你一个整数 <code>n</code> ,返回所有不同的 <strong>n<em> </em>皇后问题</strong> 的解决方案。</p><div class="original__bRMd"><div><p>每一种解法包含一个不同的 <strong>n 皇后问题</strong> 的棋子放置方案,该方案中 <code>'Q'</code> 和 <code>'.'</code> 分别代表了皇后和空位。</p><p> </p><p><strong>示例 1:</strong></p><img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0051.N-Queens/images/queens.jpg" style="width: 600px; height: 268px;" /><pre><strong>输入:</strong>n = 4<strong><br />输出:</strong>[[".Q..","...Q","Q...","..Q."],["..Q.","Q...","...Q",".Q.."]]<strong><br />解释:</strong>如上图所示,4 皇后问题存在两个不同的解法。</pre><p><strong>示例 2:</strong></p><pre><strong>输入:</strong>n = 1<strong><br />输出:</strong>[["Q"]]</pre><p> </p><p><strong>提示:</strong></p><ul> <li><code>1 <= n <= 9</code></li> <li>皇后彼此不能相互攻击,也就是说:任何两个皇后都不能处于同一条横行、纵行或斜线上。</li></ul></div></div>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -28,6 +32,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -87,7 +92,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -137,6 +144,7 @@ private:
```
### B
```
cpp
class
Solution
{
...
...
@@ -199,6 +207,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/7.leetcode-回溯算法/51.N皇后 II/solution.md
浏览文件 @
ceaae444
# N皇后 II
<div
class=
"notranslate"
>
<p><strong>
n
皇后问题
</strong>
研究的是如何将
<code>
n
</code>
个皇后放置在
<code>
n×n
</code>
的棋盘上,并且使皇后彼此之间不能相互攻击。
</p>
...
...
@@ -36,12 +37,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -56,6 +60,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -97,7 +102,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -144,6 +151,7 @@ private:
```
### B
```
cpp
class
Solution
{
...
...
@@ -194,6 +202,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/7.leetcode-回溯算法/88.格雷编码/solution.md
浏览文件 @
ceaae444
# 格雷编码
<p>
格雷编码是一个二进制数字系统,在该系统中,两个连续的数值仅有一个位数的差异。
</p>
<p>
给定一个代表编码总位数的非负整数
<em>
n
</em>
,打印其格雷编码序列。即使有多个不同答案,你也只需要返回其中一种。
</p>
<p>
格雷编码序列必须以 0 开头。
</p>
...
...
@@ -10,12 +11,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -31,6 +35,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -64,7 +69,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -84,6 +91,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -109,6 +117,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/7.leetcode-回溯算法/89.子集 II/solution.md
浏览文件 @
ceaae444
# 子集 II
<p>
给你一个整数数组
<code>
nums
</code>
,其中可能包含重复元素,请你返回该数组所有可能的子集(幂集)。
</p><p>
解集
<strong>
不能
</strong>
包含重复的子集。返回的解集中,子集可以按
<strong>
任意顺序
</strong>
排列。
</p><div
class=
"original__bRMd"
><div><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
nums = [1,2,2]
<strong><br
/>
输出:
</strong>
[[],[1],[1,2],[1,2,2],[2],[2,2]]
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
nums = [0]
<strong><br
/>
输出:
</strong>
[[],[0]]
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
1
<
=
nums.length
<=
10</
code
></li>
<li><code>
-10
<
=
nums
[
i
]
<=
10</
code
></li></ul></div></div>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -27,6 +31,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -69,7 +74,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -109,6 +116,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -141,6 +149,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/8.leetcode-贪心/121.买卖股票的最佳时机 II/solution.md
浏览文件 @
ceaae444
# 买卖股票的最佳时机 II
<p>
给定一个数组
<code>
prices
</code>
,其中
<code>
prices[i]
</code>
是一支给定股票第
<code>
i
</code>
天的价格。
</p>
<p>
设计一个算法来计算你所能获取的最大利润。你可以尽可能地完成更多的交易(多次买卖一支股票)。
</p>
...
...
@@ -44,12 +45,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -64,6 +68,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -85,7 +90,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -109,6 +116,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -133,6 +141,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/8.leetcode-贪心/133.加油站/solution.md
浏览文件 @
ceaae444
# 加油站
<p>
在一条环路上有
<em>
N
</em>
个加油站,其中第
<em>
i
</em>
个加油站有汽油
<code>
gas[i]
</code><em>
</em>
升。
</p>
<p>
你有一辆油箱容量无限的的汽车,从第
<em>
i
</em>
个加油站开往第
<em>
i+1
</em>
个加油站需要消耗汽油
<code>
cost[i]
</code><em>
</em>
升。你从其中的一个加油站出发,开始时油箱为空。
</p>
...
...
@@ -49,12 +50,15 @@ cost = [3,4,3]
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -70,6 +74,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -113,7 +118,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -152,6 +159,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -175,6 +183,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/8.leetcode-贪心/134.分发糖果/solution.md
浏览文件 @
ceaae444
# 分发糖果
<p>
老师想给孩子们分发糖果,有
<em>
N
</em>
个孩子站成了一条直线,老师会根据每个孩子的表现,预先给他们评分。
</p>
<p>
你需要按照以下要求,帮助老师给这些孩子分发糖果:
</p>
...
...
@@ -31,12 +32,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -50,6 +54,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -74,7 +79,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -101,6 +108,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -153,6 +161,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/8.leetcode-贪心/44.跳跃游戏 II/solution.md
浏览文件 @
ceaae444
# 跳跃游戏 II
<p>
给定一个非负整数数组,你最初位于数组的第一个位置。
</p>
<p>
数组中的每个元素代表你在该位置可以跳跃的最大长度。
</p>
<p>
你的目标是使用最少的跳跃次数到达数组的最后一个位置。
</p>
...
...
@@ -9,12 +10,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -30,6 +34,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -62,7 +67,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -88,6 +95,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -124,6 +132,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/8.leetcode-贪心/54.跳跃游戏/solution.md
浏览文件 @
ceaae444
# 跳跃游戏
<p>
给定一个非负整数数组
<code>
nums
</code>
,你最初位于数组的
<strong>
第一个下标
</strong>
。
</p><p>
数组中的每个元素代表你在该位置可以跳跃的最大长度。
</p><p>
判断你是否能够到达最后一个下标。
</p><p>
</p><p><strong>
示例 1:
</strong></p><pre><strong>
输入:
</strong>
nums = [2,3,1,1,4]
<strong><br
/>
输出:
</strong>
true
<strong><br
/>
解释:
</strong>
可以先跳 1 步,从下标 0 到达下标 1, 然后再从下标 1 跳 3 步到达最后一个下标。
</pre><p><strong>
示例 2:
</strong></p><pre><strong>
输入:
</strong>
nums = [3,2,1,0,4]
<strong><br
/>
输出:
</strong>
false
<strong><br
/>
解释:
</strong>
无论怎样,总会到达下标为 3 的位置。但该下标的最大跳跃长度是 0 , 所以永远不可能到达最后一个下标。
</pre><p>
</p><p><strong>
提示:
</strong></p><ul>
<li><code>
1
<
=
nums.length
<=
3
*
10<
sup
>
4
</sup></code></li>
<li><code>
0
<
=
nums
[
i
]
<=
10<
sup
>
5
</sup></code></li></ul>
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -23,6 +27,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -42,7 +47,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -63,6 +70,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -85,6 +93,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
data/3.算法高阶/8.leetcode-贪心/67.文本左右对齐/solution.md
浏览文件 @
ceaae444
# 文本左右对齐
<div
class=
"notranslate"
>
<p>
给定一个单词数组和一个长度
<em>
maxWidth
</em>
,重新排版单词,使其成为每行恰好有
<em>
maxWidth
</em>
个字符,且左右两端对齐的文本。
</p>
...
...
@@ -65,12 +66,15 @@
<p>
以下错误的选项是?
</p>
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
int
main
()
{
...
...
@@ -87,6 +91,7 @@ int main()
```
## 答案
```
cpp
class
Solution
{
...
...
@@ -153,7 +158,9 @@ public:
```
## 选项
### A
```
cpp
class
Solution
{
...
...
@@ -213,6 +220,7 @@ public:
```
### B
```
cpp
class
Solution
{
...
...
@@ -268,6 +276,7 @@ public:
```
### C
```
cpp
class
Solution
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录