From 514e9a7c95292ae6d7bb3ae9c0c5e592f005ff64 Mon Sep 17 00:00:00 2001 From: zhangzc Date: Tue, 9 Nov 2021 20:05:00 +0800 Subject: [PATCH] update leetcode and lanqiao markdown style --- .../solution.md" | 4 ++ .../solution.md" | 4 ++ .../solution.md" | 4 ++ .../solution.md" | 5 ++ .../solution.md" | 4 ++ .../solution.md" | 4 ++ .../solution.md" | 5 ++ .../solution.md" | 5 ++ .../solution.md" | 5 ++ .../solution.md" | 5 ++ .../solution.md" | 5 ++ .../solution.md" | 5 ++ .../solution.md" | 5 ++ .../solution.md" | 4 ++ .../solution.md" | 5 ++ .../solution.md" | 5 ++ .../solution.md" | 4 ++ .../solution.md" | 5 ++ .../solution.md" | 5 ++ leetcode_helper.py | 46 +++++++++++++++---- 20 files changed, 126 insertions(+), 8 deletions(-) diff --git "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/1.leetcode-\346\240\221/10.103-\344\272\214\345\217\211\346\240\221\347\232\204\351\224\257\351\275\277\345\275\242\345\261\202\345\272\217\351\201\215\345\216\206/solution.md" "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/1.leetcode-\346\240\221/10.103-\344\272\214\345\217\211\346\240\221\347\232\204\351\224\257\351\275\277\345\275\242\345\261\202\345\272\217\351\201\215\345\216\206/solution.md" index c35443aa..026a99fc 100644 --- "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/1.leetcode-\346\240\221/10.103-\344\272\214\345\217\211\346\240\221\347\232\204\351\224\257\351\275\277\345\275\242\345\261\202\345\272\217\351\201\215\345\216\206/solution.md" +++ "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/1.leetcode-\346\240\221/10.103-\344\272\214\345\217\211\346\240\221\347\232\204\351\224\257\351\275\277\345\275\242\345\261\202\345\272\217\351\201\215\345\216\206/solution.md" @@ -26,7 +26,9 @@

以下错误的选项是?

## aop + ### before + ```cpp #include using namespace std; @@ -42,11 +44,13 @@ struct TreeNode }; ``` ### after + ```cpp ``` ## 答案 + ```cpp class Solution { diff --git "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/1.leetcode-\346\240\221/8.101-\345\257\271\347\247\260\344\272\214\345\217\211\346\240\221/solution.md" "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/1.leetcode-\346\240\221/8.101-\345\257\271\347\247\260\344\272\214\345\217\211\346\240\221/solution.md" index e5609151..48d4851b 100644 --- "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/1.leetcode-\346\240\221/8.101-\345\257\271\347\247\260\344\272\214\345\217\211\346\240\221/solution.md" +++ "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/1.leetcode-\346\240\221/8.101-\345\257\271\347\247\260\344\272\214\345\217\211\346\240\221/solution.md" @@ -33,7 +33,9 @@

以下错误的选项是?

## aop + ### before + ```cpp #include using namespace std; @@ -49,11 +51,13 @@ struct TreeNode }; ``` ### after + ```cpp ``` ## 答案 + ```cpp class Solution { diff --git "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/1.leetcode-\346\240\221/9.102-\344\272\214\345\217\211\346\240\221\347\232\204\345\261\202\345\272\217\351\201\215\345\216\206/solution.md" "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/1.leetcode-\346\240\221/9.102-\344\272\214\345\217\211\346\240\221\347\232\204\345\261\202\345\272\217\351\201\215\345\216\206/solution.md" index 3a4f5665..87ec3ec8 100644 --- "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/1.leetcode-\346\240\221/9.102-\344\272\214\345\217\211\346\240\221\347\232\204\345\261\202\345\272\217\351\201\215\345\216\206/solution.md" +++ "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/1.leetcode-\346\240\221/9.102-\344\272\214\345\217\211\346\240\221\347\232\204\345\261\202\345\272\217\351\201\215\345\216\206/solution.md" @@ -28,7 +28,9 @@

以下错误的选项是?

## aop + ### before + ```cpp #include using namespace std; @@ -44,11 +46,13 @@ struct TreeNode }; ``` ### after + ```cpp ``` ## 答案 + ```cpp class Solution { diff --git "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/2.leetcode-\345\223\210\345\270\214\350\241\250/10.166-\345\210\206\346\225\260\345\210\260\345\260\217\346\225\260/solution.md" "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/2.leetcode-\345\223\210\345\270\214\350\241\250/10.166-\345\210\206\346\225\260\345\210\260\345\260\217\346\225\260/solution.md" index a4d626ff..59b9da51 100644 --- "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/2.leetcode-\345\223\210\345\270\214\350\241\250/10.166-\345\210\206\346\225\260\345\210\260\345\260\217\346\225\260/solution.md" +++ "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/2.leetcode-\345\223\210\345\270\214\350\241\250/10.166-\345\210\206\346\225\260\345\210\260\345\260\217\346\225\260/solution.md" @@ -1,4 +1,5 @@ # 分数到小数 +

给定两个整数,分别表示分数的分子 numerator 和分母 denominator,以 字符串形式返回小数

如果小数部分为循环小数,则将循环的部分括在括号内。

@@ -56,12 +57,15 @@

以下错误的选项是?

## aop + ### before + ```cpp #include using namespace std; ``` ### after + ```cpp int main() { @@ -75,6 +79,7 @@ int main() ``` ## 答案 + ```cpp class Solution { diff --git "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/2.leetcode-\345\223\210\345\270\214\350\241\250/7.126-\345\215\225\350\257\215\346\216\245\351\276\231 II/solution.md" "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/2.leetcode-\345\223\210\345\270\214\350\241\250/7.126-\345\215\225\350\257\215\346\216\245\351\276\231 II/solution.md" index d775371e..412958c7 100644 --- "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/2.leetcode-\345\223\210\345\270\214\350\241\250/7.126-\345\215\225\350\257\215\346\216\245\351\276\231 II/solution.md" +++ "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/2.leetcode-\345\223\210\345\270\214\350\241\250/7.126-\345\215\225\350\257\215\346\216\245\351\276\231 II/solution.md" @@ -51,12 +51,15 @@

以下错误的选项是?

## aop + ### before + ```cpp #include using namespace std; ``` ### after + ```cpp int main() { @@ -76,6 +79,7 @@ int main() ``` ## 答案 + ```cpp class Solution { diff --git "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/2.leetcode-\345\223\210\345\270\214\350\241\250/8.127-\345\215\225\350\257\215\346\216\245\351\276\231/solution.md" "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/2.leetcode-\345\223\210\345\270\214\350\241\250/8.127-\345\215\225\350\257\215\346\216\245\351\276\231/solution.md" index f48a0009..d4c450b7 100644 --- "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/2.leetcode-\345\223\210\345\270\214\350\241\250/8.127-\345\215\225\350\257\215\346\216\245\351\276\231/solution.md" +++ "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/2.leetcode-\345\223\210\345\270\214\350\241\250/8.127-\345\215\225\350\257\215\346\216\245\351\276\231/solution.md" @@ -44,12 +44,15 @@

以下错误的选项是?

## aop + ### before + ```cpp #include using namespace std; ``` ### after + ```cpp int main() { @@ -64,6 +67,7 @@ int main() ``` ## 答案 + ```cpp class Solution { diff --git "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/2.leetcode-\345\223\210\345\270\214\350\241\250/9.128-\346\234\200\351\225\277\350\277\236\347\273\255\345\272\217\345\210\227/solution.md" "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/2.leetcode-\345\223\210\345\270\214\350\241\250/9.128-\346\234\200\351\225\277\350\277\236\347\273\255\345\272\217\345\210\227/solution.md" index 2aca266e..85d13222 100644 --- "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/2.leetcode-\345\223\210\345\270\214\350\241\250/9.128-\346\234\200\351\225\277\350\277\236\347\273\255\345\272\217\345\210\227/solution.md" +++ "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/2.leetcode-\345\223\210\345\270\214\350\241\250/9.128-\346\234\200\351\225\277\350\277\236\347\273\255\345\272\217\345\210\227/solution.md" @@ -1,4 +1,5 @@ # 最长连续序列 +

给定一个未排序的整数数组 nums ,找出数字连续的最长序列(不要求序列元素在原数组中连续)的长度。

请你设计并实现时间复杂度为 O(n) 的算法解决此问题。

@@ -31,12 +32,15 @@

以下错误的选项是?

## aop + ### before + ```cpp #include using namespace std; ``` ### after + ```cpp int main() { @@ -50,6 +54,7 @@ int main() ``` ## 答案 + ```cpp class Solution { diff --git "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/3.leetcode-\345\233\276\344\270\216\346\220\234\347\264\242/10.130-\350\242\253\345\233\264\347\273\225\347\232\204\345\214\272\345\237\237/solution.md" "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/3.leetcode-\345\233\276\344\270\216\346\220\234\347\264\242/10.130-\350\242\253\345\233\264\347\273\225\347\232\204\345\214\272\345\237\237/solution.md" index d21a6f69..5d6d8905 100644 --- "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/3.leetcode-\345\233\276\344\270\216\346\220\234\347\264\242/10.130-\350\242\253\345\233\264\347\273\225\347\232\204\345\214\272\345\237\237/solution.md" +++ "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/3.leetcode-\345\233\276\344\270\216\346\220\234\347\264\242/10.130-\350\242\253\345\233\264\347\273\225\347\232\204\345\214\272\345\237\237/solution.md" @@ -1,4 +1,5 @@ # 被围绕的区域 + 给你一个 m x n 的矩阵 board ,由若干字符 'X''O' ,找到所有被 'X' 围绕的区域,并将这些区域里所有的 'O''X' 填充。
@@ -35,12 +36,15 @@

以下错误的选项是?

## aop + ### before + ```cpp #include using namespace std; ``` ### after + ```cpp int main() { @@ -59,6 +63,7 @@ int main() ``` ## 答案 + ```cpp class Solution { diff --git "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/3.leetcode-\345\233\276\344\270\216\346\220\234\347\264\242/8.112-\350\267\257\345\276\204\346\200\273\345\222\214/solution.md" "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/3.leetcode-\345\233\276\344\270\216\346\220\234\347\264\242/8.112-\350\267\257\345\276\204\346\200\273\345\222\214/solution.md" index 97bf6f21..6f82994a 100644 --- "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/3.leetcode-\345\233\276\344\270\216\346\220\234\347\264\242/8.112-\350\267\257\345\276\204\346\200\273\345\222\214/solution.md" +++ "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/3.leetcode-\345\233\276\344\270\216\346\220\234\347\264\242/8.112-\350\267\257\345\276\204\346\200\273\345\222\214/solution.md" @@ -1,4 +1,5 @@ # 路径总和 +

给你二叉树的根节点 root 和一个表示目标和的整数 targetSum ,判断该树中是否存在 根节点到叶子节点 的路径,这条路径上所有节点值相加等于目标和 targetSum

叶子节点 是指没有子节点的节点。

@@ -39,7 +40,9 @@

以下错误的选项是?

## aop + ### before + ```cpp #include using namespace std; @@ -55,11 +58,13 @@ struct TreeNode }; ``` ### after + ```cpp ``` ## 答案 + ```cpp 其他三个都是错的 ``` diff --git "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/3.leetcode-\345\233\276\344\270\216\346\220\234\347\264\242/9.113-\350\267\257\345\276\204\346\200\273\345\222\214 II/solution.md" "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/3.leetcode-\345\233\276\344\270\216\346\220\234\347\264\242/9.113-\350\267\257\345\276\204\346\200\273\345\222\214 II/solution.md" index f85b18be..07e4d765 100644 --- "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/3.leetcode-\345\233\276\344\270\216\346\220\234\347\264\242/9.113-\350\267\257\345\276\204\346\200\273\345\222\214 II/solution.md" +++ "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/3.leetcode-\345\233\276\344\270\216\346\220\234\347\264\242/9.113-\350\267\257\345\276\204\346\200\273\345\222\214 II/solution.md" @@ -1,4 +1,5 @@ # 路径总和 II +

给你二叉树的根节点 root 和一个整数目标和 targetSum ,找出所有 从根节点到叶子节点 路径总和等于给定目标和的路径。

叶子节点 是指没有子节点的节点。

@@ -43,7 +44,9 @@

以下错误的选项是?

## aop + ### before + ```cpp #include using namespace std; @@ -60,11 +63,13 @@ struct TreeNode ``` ### after + ```cpp ``` ## 答案 + ```cpp class Solution { diff --git "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/5.leetcode-\350\256\276\350\256\241/10.297-\344\272\214\345\217\211\346\240\221\347\232\204\345\272\217\345\210\227\345\214\226\344\270\216\345\217\215\345\272\217\345\210\227\345\214\226/solution.md" "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/5.leetcode-\350\256\276\350\256\241/10.297-\344\272\214\345\217\211\346\240\221\347\232\204\345\272\217\345\210\227\345\214\226\344\270\216\345\217\215\345\272\217\345\210\227\345\214\226/solution.md" index 3567fb83..360dd42f 100644 --- "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/5.leetcode-\350\256\276\350\256\241/10.297-\344\272\214\345\217\211\346\240\221\347\232\204\345\272\217\345\210\227\345\214\226\344\270\216\345\217\215\345\272\217\345\210\227\345\214\226/solution.md" +++ "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/5.leetcode-\350\256\276\350\256\241/10.297-\344\272\214\345\217\211\346\240\221\347\232\204\345\272\217\345\210\227\345\214\226\344\270\216\345\217\215\345\272\217\345\210\227\345\214\226/solution.md" @@ -1,4 +1,5 @@ # 二叉树的序列化与反序列化 +

序列化是将一个数据结构或者对象转换为连续的比特位的操作,进而可以将转换后的数据存储在一个文件或者内存中,同时也可以通过网络传输到另一个计算机环境,采取相反方式重构得到原数据。

请设计一个算法来实现二叉树的序列化与反序列化。这里不限定你的序列 / 反序列化算法执行逻辑,你只需要保证一个二叉树可以被序列化为一个字符串并且将这个字符串反序列化为原始的树结构。

@@ -47,7 +48,9 @@

以下错误的选项是?

## aop + ### before + ```cpp #include using namespace std; @@ -63,11 +66,13 @@ struct TreeNode }; ``` ### after + ```cpp ``` ## 答案 + ```cpp class Codec { diff --git "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/5.leetcode-\350\256\276\350\256\241/6.173-\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\277\255\344\273\243\345\231\250/solution.md" "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/5.leetcode-\350\256\276\350\256\241/6.173-\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\277\255\344\273\243\345\231\250/solution.md" index f538c8fe..eb035e87 100644 --- "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/5.leetcode-\350\256\276\350\256\241/6.173-\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\277\255\344\273\243\345\231\250/solution.md" +++ "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/5.leetcode-\350\256\276\350\256\241/6.173-\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\277\255\344\273\243\345\231\250/solution.md" @@ -1,4 +1,5 @@ # 二叉搜索树迭代器 + 实现一个二叉搜索树迭代器类BSTIterator ,表示一个按中序遍历二叉搜索树(BST)的迭代器:
@@ -59,7 +60,9 @@ bSTIterator.hasNext(); // 返回 False

以下错误的选项是?

## aop + ### before + ```cpp #include using namespace std; @@ -75,6 +78,7 @@ struct TreeNode }; ``` ### after + ```cpp /** * Your BSTIterator object will be instantiated and called as such: @@ -85,6 +89,7 @@ struct TreeNode ``` ## 答案 + ```cpp class BSTIterator { diff --git "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/5.leetcode-\350\256\276\350\256\241/7.208-\345\256\236\347\216\260 Trie (\345\211\215\347\274\200\346\240\221)/solution.md" "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/5.leetcode-\350\256\276\350\256\241/7.208-\345\256\236\347\216\260 Trie (\345\211\215\347\274\200\346\240\221)/solution.md" index 2d3d063c..db186e3a 100644 --- "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/5.leetcode-\350\256\276\350\256\241/7.208-\345\256\236\347\216\260 Trie (\345\211\215\347\274\200\346\240\221)/solution.md" +++ "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/5.leetcode-\350\256\276\350\256\241/7.208-\345\256\236\347\216\260 Trie (\345\211\215\347\274\200\346\240\221)/solution.md" @@ -1,4 +1,5 @@ # 实现 Trie (前缀树) +

Trie(发音类似 "try")或者说 前缀树 是一种树形数据结构,用于高效地存储和检索字符串数据集中的键。这一数据结构有相当多的应用情景,例如自动补完和拼写检查。

请你实现 Trie 类:

@@ -44,17 +45,21 @@ trie.search("app"); // 返回 True

以下错误的选项是?

## aop + ### before + ```cpp #include using namespace std; ``` ### after + ```cpp ``` ## 答案 + ```cpp class TrieNode { diff --git "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/5.leetcode-\350\256\276\350\256\241/8.535-TinyURL \347\232\204\345\212\240\345\257\206\344\270\216\350\247\243\345\257\206/solution.md" "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/5.leetcode-\350\256\276\350\256\241/8.535-TinyURL \347\232\204\345\212\240\345\257\206\344\270\216\350\247\243\345\257\206/solution.md" index 674fdb13..81a1dc5a 100644 --- "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/5.leetcode-\350\256\276\350\256\241/8.535-TinyURL \347\232\204\345\212\240\345\257\206\344\270\216\350\247\243\345\257\206/solution.md" +++ "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/5.leetcode-\350\256\276\350\256\241/8.535-TinyURL \347\232\204\345\212\240\345\257\206\344\270\216\350\247\243\345\257\206/solution.md" @@ -8,12 +8,15 @@

以下错误的选项是?

## aop + ### before + ```cpp #include using namespace std; ``` ### after + ```cpp // Your Solution object will be instantiated and called as such: // Solution solution; @@ -21,6 +24,7 @@ using namespace std; ``` ## 答案 + ```cpp class Solution { diff --git "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/5.leetcode-\350\256\276\350\256\241/9.341-\346\211\201\345\271\263\345\214\226\345\265\214\345\245\227\345\210\227\350\241\250\350\277\255\344\273\243\345\231\250/solution.md" "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/5.leetcode-\350\256\276\350\256\241/9.341-\346\211\201\345\271\263\345\214\226\345\265\214\345\245\227\345\210\227\350\241\250\350\277\255\344\273\243\345\231\250/solution.md" index 762ed782..1e8e1676 100644 --- "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/5.leetcode-\350\256\276\350\256\241/9.341-\346\211\201\345\271\263\345\214\226\345\265\214\345\245\227\345\210\227\350\241\250\350\277\255\344\273\243\345\231\250/solution.md" +++ "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/5.leetcode-\350\256\276\350\256\241/9.341-\346\211\201\345\271\263\345\214\226\345\265\214\345\245\227\345\210\227\350\241\250\350\277\255\344\273\243\345\231\250/solution.md" @@ -1,4 +1,5 @@ # 扁平化嵌套列表迭代器 +

给你一个嵌套的整数列表 nestedList 。每个元素要么是一个整数,要么是一个列表;该列表的元素也可能是整数或者是其他列表。请你实现一个迭代器将其扁平化,使之能够遍历这个列表中的所有整数。

实现扁平迭代器类 NestedIterator

@@ -49,7 +50,9 @@ return res

以下错误的选项是?

## aop + ### before + ```cpp #include using namespace std; @@ -72,11 +75,13 @@ public: }; ``` ### after + ```cpp ``` ## 答案 + ```cpp class NestedIterator { diff --git "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/8.leetcode-\350\264\252\345\277\203/10.330-\346\214\211\350\246\201\346\261\202\350\241\245\351\275\220\346\225\260\347\273\204/solution.md" "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/8.leetcode-\350\264\252\345\277\203/10.330-\346\214\211\350\246\201\346\261\202\350\241\245\351\275\220\346\225\260\347\273\204/solution.md" index 693080f4..a64713b0 100644 --- "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/8.leetcode-\350\264\252\345\277\203/10.330-\346\214\211\350\246\201\346\261\202\350\241\245\351\275\220\346\225\260\347\273\204/solution.md" +++ "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/8.leetcode-\350\264\252\345\277\203/10.330-\346\214\211\350\246\201\346\261\202\350\241\245\351\275\220\346\225\260\347\273\204/solution.md" @@ -1,4 +1,5 @@ # 按要求补齐数组 +

给定一个已排序的正整数数组 nums,和一个正整数 n 。从 [1, n] 区间内选取任意个数字补充到 nums 中,使得 [1, n] 区间内的任何数字都可以用 nums 中某几个数字的和来表示。请输出满足上述要求的最少需要补充的数字个数。

示例 1:

@@ -27,13 +28,16 @@

以下错误的选项是?

## aop + ### before + ```cpp #include using namespace std; ``` ### after + ```cpp int main() { @@ -48,6 +52,7 @@ int main() ``` ## 答案 + ```cpp class Solution { diff --git "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/8.leetcode-\350\264\252\345\277\203/7.179-\346\234\200\345\244\247\346\225\260/solution.md" "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/8.leetcode-\350\264\252\345\277\203/7.179-\346\234\200\345\244\247\346\225\260/solution.md" index bbad34c1..6e8da4cf 100644 --- "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/8.leetcode-\350\264\252\345\277\203/7.179-\346\234\200\345\244\247\346\225\260/solution.md" +++ "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/8.leetcode-\350\264\252\345\277\203/7.179-\346\234\200\345\244\247\346\225\260/solution.md" @@ -45,12 +45,15 @@

以下错误的选项是?

## aop + ### before + ```cpp #include using namespace std; ``` ### after + ```cpp int main() { @@ -64,6 +67,7 @@ int main() ``` ## 答案 + ```cpp class Solution { diff --git "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/8.leetcode-\350\264\252\345\277\203/8.316-\345\216\273\351\231\244\351\207\215\345\244\215\345\255\227\346\257\215/solution.md" "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/8.leetcode-\350\264\252\345\277\203/8.316-\345\216\273\351\231\244\351\207\215\345\244\215\345\255\227\346\257\215/solution.md" index b3875c8f..bb7af673 100644 --- "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/8.leetcode-\350\264\252\345\277\203/8.316-\345\216\273\351\231\244\351\207\215\345\244\215\345\255\227\346\257\215/solution.md" +++ "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/8.leetcode-\350\264\252\345\277\203/8.316-\345\216\273\351\231\244\351\207\215\345\244\215\345\255\227\346\257\215/solution.md" @@ -1,4 +1,5 @@ # 去除重复字母 +

给你一个字符串 s ,请你去除字符串中重复的字母,使得每个字母只出现一次。需保证 返回结果的字典序最小(要求不能打乱其他字符的相对位置)。

注意:该题与 1081 https://leetcode-cn.com/problems/smallest-subsequence-of-distinct-characters 相同

@@ -30,12 +31,15 @@

以下错误的选项是?

## aop + ### before + ```cpp #include using namespace std; ``` ### after + ```cpp int main() { @@ -49,6 +53,7 @@ int main() ``` ## 答案 + ```cpp class Solution diff --git "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/8.leetcode-\350\264\252\345\277\203/9.321-\346\213\274\346\216\245\346\234\200\345\244\247\346\225\260/solution.md" "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/8.leetcode-\350\264\252\345\277\203/9.321-\346\213\274\346\216\245\346\234\200\345\244\247\346\225\260/solution.md" index 3728fb4b..203337c8 100644 --- "a/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/8.leetcode-\350\264\252\345\277\203/9.321-\346\213\274\346\216\245\346\234\200\345\244\247\346\225\260/solution.md" +++ "b/data/3.\347\256\227\346\263\225\351\253\230\351\230\266/8.leetcode-\350\264\252\345\277\203/9.321-\346\213\274\346\216\245\346\234\200\345\244\247\346\225\260/solution.md" @@ -1,4 +1,5 @@ # 拼接最大数 +

给定长度分别为 m 和 n 的两个数组,其元素由 0-9 构成,表示两个自然数各位上的数字。现在从这两个数组中选出 k (k <= m + n) 个数字拼接成一个新的数,要求从同一个数组中取出的数字保持其在原数组中的相对顺序。

求满足该条件的最大数。结果返回一个表示该最大数的长度为 k 的数组。

@@ -35,12 +36,15 @@ k = 3

以下错误的选项是?

## aop + ### before + ```cpp #include using namespace std; ``` ### after + ```cpp int main() { @@ -57,6 +61,7 @@ int main() ``` ## 答案 + ```cpp class Solution { diff --git a/leetcode_helper.py b/leetcode_helper.py index b0e4e071..303d4a36 100644 --- a/leetcode_helper.py +++ b/leetcode_helper.py @@ -273,17 +273,47 @@ def modify_config_and_dir_name_new(): for idx, tem_dir in enumerate(exercises_dirs): config_path = os.path.join(tem_dir, 'config.json') solution_md_path = os.path.join(tem_dir, 'solution.md') + + if dir == "data/1.算法初阶": + title = tem_dir.split('/')[-1].split('.')[-1] + else: + title = tem_dir.split('/')[-1].split('-')[-1] with open(solution_md_path, 'r', encoding='utf-8') as f: solution_md_data = f.read() - print(config_path) - with open(config_path, 'r', encoding='utf-8') as f: - config_data = json.load(f) - del config_data['title'] - config_data_json = json.dumps(config_data, ensure_ascii=False, indent=2) - print(config_data_json) + if solution_md_data.find('# {}\n\n'.format(title)) == -1: + solution_md_data = solution_md_data.replace('# {}'.format(title), '# {}\n'.format(title)) + print(tem_dir) + if solution_md_data.find('## aop\n\n') == -1: + solution_md_data = solution_md_data.replace('## aop', '## aop\n') + + if solution_md_data.find('## 答案\n\n') == -1: + solution_md_data = solution_md_data.replace('## 答案', '## 答案\n') + + if solution_md_data.find('## 选项\n\n') == -1: + solution_md_data = solution_md_data.replace('## 选项', '## 选项\n') + + if solution_md_data.find('### before\n\n') == -1: + solution_md_data = solution_md_data.replace('### before', '### before\n') - with open(config_path, 'w', encoding='utf-8') as f: - f.write(config_data_json) + if solution_md_data.find('### after\n\n') == -1: + solution_md_data = solution_md_data.replace('### after', '### after\n') + + if solution_md_data.find('\n\n```cpp') == -1: + solution_md_data = solution_md_data.replace('```cpp', '\n```cpp') + + with open(solution_md_path, 'w', encoding='utf-8') as f: + f.write(solution_md_data) + + + + # with open(config_path, 'r', encoding='utf-8') as f: + # config_data = json.load(f) + # del config_data['title'] + # config_data_json = json.dumps(config_data, ensure_ascii=False, indent=2) + # print(config_data_json) + + # with open(config_path, 'w', encoding='utf-8') as f: + # f.write(config_data_json) -- GitLab