提交 c4582537 编写于 作者: 每日一练社区's avatar 每日一练社区

update code

上级 46028b85
<p>罗马数字包含以下七种字符: <code>I</code>, <code>V</code>, <code>X</code>, <code>L</code><code>C</code><code>D</code> 和 <code>M</code> <div class="notranslate">
</p> <p>罗马数字包含以下七种字符:&nbsp;<code>I</code>&nbsp;<code>V</code>&nbsp;<code>X</code>&nbsp;<code>L</code><code>C</code><code>D</code>&nbsp;&nbsp;<code>M</code>
</p>
<pre> <pre><strong>字符</strong> <strong>数值</strong>
<strong>字符</strong> <strong>数值</strong>
I 1 I 1
V 5 V 5
X 10 X 10
...@@ -11,66 +11,59 @@ C 100 ...@@ -11,66 +11,59 @@ C 100
D 500 D 500
M 1000</pre> M 1000</pre>
<p>例如, 罗马数字 2 写做 <code>II</code> ,即为两个并列的 1。12 写做 <code>XII</code> ,即为 <code>X</code> + <code>II</code> 。 27 <p>例如, 罗马数字 2 写做&nbsp;<code>II</code>&nbsp;,即为两个并列的 1。12
写做  <code>XXVII</code>, 即为 <code>XX</code> + <code>V</code> + <code>II</code> 。</p> 写做&nbsp;<code>XII</code>&nbsp;,即为&nbsp;<code>X</code>&nbsp;+&nbsp;<code>II</code>&nbsp;。 27
写做&nbsp;&nbsp;<code>XXVII</code>,
即为&nbsp;<code>XX</code>&nbsp;+&nbsp;<code>V</code>&nbsp;+&nbsp;<code>II</code>&nbsp;</p>
<p>通常情况下,罗马数字中小的数字在大的数字的右边。但也存在特例,例如 4 不写做 <code>IIII</code>,而是 <code>IV</code>。数字 1 在数字 5 的左边,所表示的数等于大数 5 减小数 1 得到的数值 4 <p>通常情况下,罗马数字中小的数字在大的数字的右边。但也存在特例,例如 4 不写做&nbsp;<code>IIII</code>,而是&nbsp;<code>IV</code>。数字 1 在数字 5 的左边,所表示的数等于大数 5
。同样地,数字 9 表示为 <code>IX</code>。这个特殊的规则只适用于以下六种情况:</p> 减小数 1 得到的数值 4 。同样地,数字 9 表示为&nbsp;<code>IX</code>。这个特殊的规则只适用于以下六种情况:</p>
<ul> <ul>
<li><code>I</code> 可以放在 <code>V</code> (5) 和 <code>X</code> (10) 的左边,来表示 4 和 9。</li> <li><code>I</code>&nbsp;可以放在&nbsp;<code>V</code>&nbsp;(5) 和&nbsp;<code>X</code>&nbsp;(10) 的左边,来表示 4 和 9。</li>
<li><code>X</code> 可以放在 <code>L</code> (50) 和 <code>C</code> (100) 的左边,来表示 40 和 90。 </li> <li><code>X</code>&nbsp;可以放在&nbsp;<code>L</code>&nbsp;(50) 和&nbsp;<code>C</code>&nbsp;(100) 的左边,来表示 40
<li><code>C</code> 可以放在 <code>D</code> (500) 和 <code>M</code> (1000) 的左边,来表示 400 和 900。</li> &nbsp;90。&nbsp;</li>
</ul> <li><code>C</code>&nbsp;可以放在&nbsp;<code>D</code>&nbsp;(500) 和&nbsp;<code>M</code>&nbsp;(1000) 的左边,来表示&nbsp;400
&nbsp;900。</li>
</ul>
<p>给定一个罗马数字,将其转换成整数。输入确保在 1 到 3999 的范围内</p> <p>给你一个整数,将其转为罗马数字</p>
<p> </p> <p>&nbsp;</p>
<p><strong>示例 1:</strong></p> <p><strong>示例&nbsp;1:</strong></p>
<pre> <pre><strong>输入:</strong>&nbsp;num = 3
<strong>输入:</strong> "III" <strong><br />输出:</strong> "III"</pre>
<strong>输出:</strong> 3</pre>
<p><strong>示例 2:</strong></p> <p><strong>示例&nbsp;2:</strong></p>
<pre> <pre><strong>输入:</strong>&nbsp;num = 4
<strong>输入:</strong> "IV" <strong><br />输出:</strong> "IV"</pre>
<strong>输出:</strong> 4</pre>
<p><strong>示例 3:</strong></p> <p><strong>示例&nbsp;3:</strong></p>
<pre> <pre><strong>输入:</strong>&nbsp;num = 9
<strong>输入:</strong> "IX" <strong><br />输出:</strong> "IX"</pre>
<strong>输出:</strong> 9</pre>
<p><strong>示例 4:</strong></p> <p><strong>示例&nbsp;4:</strong></p>
<pre> <pre><strong>输入:</strong>&nbsp;num = 58
<strong>输入:</strong> "LVIII" <strong><br />输出:</strong> "LVIII"
<strong>输出:</strong> 58 <strong><br />解释:</strong> L = 50, V = 5, III = 3.
<strong>解释:</strong> L = 50, V= 5, III = 3. </pre>
</pre>
<p><strong>示例 5:</strong></p> <p><strong>示例&nbsp;5:</strong></p>
<pre> <pre><strong>输入:</strong>&nbsp;num = 1994
<strong>输入:</strong> "MCMXCIV" <strong><br />输出:</strong> "MCMXCIV"
<strong>输出:</strong> 1994 <strong><br />解释:</strong> M = 1000, CM = 900, XC = 90, IV = 4.</pre>
<strong>解释:</strong> M = 1000, CM = 900, XC = 90, IV = 4.</pre>
<p> </p> <p>&nbsp;</p>
<p><strong>提示:</strong></p> <p><strong>提示:</strong></p>
<ul> <ul>
<li><code>1 <= s.length <= 15</code></li> <li><code>1 &lt;= num &lt;= 3999</code></li>
<li><code>s</code> 仅含字符 <code>('I', 'V', 'X', 'L', 'C', 'D', 'M')</code></li> </ul>
<li>题目数据保证 <code>s</code> 是一个有效的罗马数字,且表示整数在范围 <code>[1, 3999]</code></li> </div>
<li>题目所给测试用例皆符合罗马数字书写规则,不会出现跨位等情况。</li> \ No newline at end of file
<li>IL 和 IM 这样的例子并不符合题目要求,49 应该写作 XLIX,999 应该写作 CMXCIX 。</li>
<li>关于罗马数字的详尽书写规则,可以参考 <a
href="https://b2b.partcommunity.com/community/knowledge/zh_CN/detail/10753/%E7%BD%97%E9%A9%AC%E6%95%B0%E5%AD%97#knowledge_article">罗马数字
- Mathematics </a></li>
</ul>
\ No newline at end of file
# 最长有效括号
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 最大子序和
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 螺旋矩阵
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 跳跃游戏
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 合并区间
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 插入区间
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 最后一个单词的长度
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 螺旋矩阵 II
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 排列序列
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 旋转链表
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 不同路径
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 不同路径 II
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 最小路径和
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 有效数字
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 加一
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 二进制求和
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 文本左右对齐
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# x 的平方根
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 爬楼梯
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 简化路径
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 编辑距离
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 矩阵置零
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 搜索二维矩阵
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 颜色分类
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 最小覆盖子串
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 组合
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 子集
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 单词搜索
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 删除有序数组中的重复项 II
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 搜索旋转排序数组 II
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 删除排序链表中的重复元素 II
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 删除排序链表中的重复元素
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 柱状图中最大的矩形
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 最大矩形
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 分隔链表
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 扰乱字符串
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 合并两个有序数组
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 格雷编码
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 子集 II
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 解码方法
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 反转链表 II
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 复原 IP 地址
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 二叉树的中序遍历
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 不同的二叉搜索树 II
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 不同的二叉搜索树
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 交错字符串
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 验证二叉搜索树
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 恢复二叉搜索树
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
# 相同的树
以下错误的选项是?
## aop
### before
```cpp
```
### after
```cpp
```
## 答案
```cpp
```
## 选项
### A
```cpp
```
### B
```cpp
```
### C
```cpp
```
...@@ -51,6 +51,28 @@ def leetcode_helper(): ...@@ -51,6 +51,28 @@ def leetcode_helper():
pass pass
# print("该路径不存在,请检查: {}".format(desc_src_path)) # print("该路径不存在,请检查: {}".format(desc_src_path))
leetcode_helper() def leetcode_helper_delete_md():
\ No newline at end of file data_dir = 'data/3.算法高阶/1.leetcode'
dirs_ = os.listdir(data_dir)
dirs = []
for dir in dirs_:
dir = os.path.join(data_dir, dir)
if os.path.isdir(dir):
dirs.append(dir)
for dir in dirs:
assert os.path.isdir(dir)
exercises_id = dir.split('/')[-1].split('_')[0]
title = dir.split('/')[-1].split('_')[1]
if 0 <= int(exercises_id) and int(exercises_id) < 100:
solution_md_path = os.path.join(dir, 'solution.md')
# print(solution_md_path)
with open('leetcode_template.md', 'r', encoding='utf-8') as f:
template = f.read()
template = template.replace('# 两数之和', '# {}'.format(title))
with open(solution_md_path, 'r', encoding='utf-8') as f:
leetcode_solution_md_data = f.read()
if leetcode_solution_md_data == template:
os.remove(solution_md_path)
leetcode_helper_delete_md()
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册