提交 c8bffe7d 编写于 作者: L luxin

add number for keywords_must

上级 60b470e6
import json
import os
import re
import ipdb
def load_json(path):
""" load_json(path:str)->jsObject
从指定文件读取内容,解析为 json 返回
@param path: 文件路径
@return: 解析后的 json
"""
with open(path) as f:
data = f.read()
return json.loads(data)
def dump_json(path, data):
""" dump_json(path:str, data:obj)->None
从指定文件读取内容,解析为 json 返回
@param path: 文件路径
@param data: json 对象
@return: None
"""
with open(path, "w+") as df:
df.write(json.dumps(data, indent=2, ensure_ascii=False))
def add_number():
data_root_dir = "./data"
data_level_dir_list = [
os.path.join(data_root_dir, _dir) for _dir in os.listdir(data_root_dir)]
for data_level_dir in data_level_dir_list:
if os.path.isfile(data_level_dir) is True:
continue
_1st_layer_dir_list = [
os.path.join(data_level_dir, _dir) for _dir in os.listdir(data_level_dir)]
for _1st_layer_dir in _1st_layer_dir_list:
if _1st_layer_dir.find("leetcode") == -1:
continue
_2nd_layer_dir_list = [
os.path.join(_1st_layer_dir, _dir) for _dir in os.listdir(_1st_layer_dir)]
for _2nd_layer_dir in _2nd_layer_dir_list:
if os.path.isfile(_2nd_layer_dir) is True:
continue
_basename = os.path.basename(_2nd_layer_dir)
_basename = re.sub(r"^[0-9]{1,3}?\.", "", _basename)
number = str(_basename.split("-")[0])
config_file_name = os.path.join(_2nd_layer_dir, "config.json")
config = load_json(config_file_name)
for index, item in enumerate(config["keywords_must"]):
if isinstance(item, list):
if number in item:
continue
item.append(number)
config["keywords_must"][index] = item
dump_json(config_file_name, config)
def main():
add_number()
if __name__=="__main__":
main()
\ No newline at end of file
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"螺旋矩阵 II"
"螺旋矩阵 II",
"59"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"旋转图像"
"旋转图像",
"48"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"两数之和"
"两数之和",
"1"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"螺旋矩阵"
"螺旋矩阵",
"54"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"删除有序数组中的重复项 II"
"删除有序数组中的重复项 II",
"80"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"合并区间"
"合并区间",
"56"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"矩阵置零"
"矩阵置零",
"73"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"搜索二维矩阵"
"搜索二维矩阵",
"74"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"搜索插入位置"
"搜索插入位置",
"35"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"搜索旋转排序数组 II"
"搜索旋转排序数组 II",
"81"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"四数之和"
"四数之和",
"18"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"插入区间"
"插入区间",
"57"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"寻找两个正序数组的中位数"
"寻找两个正序数组的中位数",
"4"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"子集"
"子集",
"78"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"搜索旋转排序数组"
"搜索旋转排序数组",
"33"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"三数之和"
"三数之和",
"15"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"在排序数组中查找元素的第一个和最后一个位置"
"在排序数组中查找元素的第一个和最后一个位置",
"34"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"删除排序链表中的重复元素 II"
"删除排序链表中的重复元素 II",
"82"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"合并两个有序链表"
"合并两个有序链表",
"21"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"删除链表的倒数第 N 个结点"
"删除链表的倒数第 N 个结点",
"19"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"删除排序链表中的重复元素"
"删除排序链表中的重复元素",
"83"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"K 个一组翻转链表"
"K 个一组翻转链表",
"25"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"分隔链表"
"分隔链表",
"86"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"合并K个升序链表"
"合并K个升序链表",
"23"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"反转链表 II"
"反转链表 II",
"92"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"两数相加"
"两数相加",
"2"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"两两交换链表中的节点"
"两两交换链表中的节点",
"24"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"最后一个单词的长度"
"最后一个单词的长度",
"58"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"实现 strStr()"
"实现 strStr()",
"28"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"交错字符串"
"交错字符串",
"97"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"复原 IP 地址"
"复原 IP 地址",
"93"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"字符串转换整数 (atoi)"
"字符串转换整数 (atoi)",
"8"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"外观数列"
"外观数列",
"38"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"无重复字符的最长子串"
"无重复字符的最长子串",
"3"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"Z 字形变换"
"Z 字形变换",
"6"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"最长公共前缀"
"最长公共前缀",
"14"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"字符串相乘"
"字符串相乘",
"43"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"有效数字"
"有效数字",
"65"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"基本计算器 II"
"基本计算器 II",
"227"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"接雨水"
"接雨水",
"42"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"简化路径"
"简化路径",
"71"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"有效的括号"
"有效的括号",
"20"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"基本计算器"
"基本计算器",
"224"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"最长有效括号"
"最长有效括号",
"32"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"最小栈"
"最小栈",
"155"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"天际线问题"
"天际线问题",
"218"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"柱状图中最大的矩形"
"柱状图中最大的矩形",
"84"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"逆波兰表达式求值"
"逆波兰表达式求值",
"150"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"翻转对"
"翻转对",
"493"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"有序矩阵中第 K 小的元素"
"有序矩阵中第 K 小的元素",
"378"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"摆动排序 II"
"摆动排序 II",
"324"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"H 指数"
"H 指数",
"274"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"前 K 个高频元素"
"前 K 个高频元素",
"347"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"俄罗斯套娃信封问题"
"俄罗斯套娃信封问题",
"354"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"最大间距"
"最大间距",
"164"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"区间和的个数"
"区间和的个数",
"327"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"排序数组"
"排序数组",
"912"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"计算右侧小于当前元素的个数"
"计算右侧小于当前元素的个数",
"315"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"颜色分类"
"颜色分类",
"75"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"最接近的三数之和"
"最接近的三数之和",
"16"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"盛最多水的容器"
"盛最多水的容器",
"11"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"下一个排列"
"下一个排列",
"31"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"环形链表 II"
"环形链表 II",
"142"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"环形链表"
"环形链表",
"141"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"旋转链表"
"旋转链表",
"61"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"删除有序数组中的重复项"
"删除有序数组中的重复项",
"26"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"移除元素"
"移除元素",
"27"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"合并两个有序数组"
"合并两个有序数组",
"88"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"不同的二叉搜索树 II"
"不同的二叉搜索树 II",
"95"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"二叉树的锯齿形层序遍历"
"二叉树的锯齿形层序遍历",
"103"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"相同的树"
"相同的树",
"100"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"二叉树中的最大路径和"
"二叉树中的最大路径和",
"124"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"验证二叉搜索树"
"验证二叉搜索树",
"98"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"不同的二叉搜索树"
"不同的二叉搜索树",
"96"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"恢复二叉搜索树"
"恢复二叉搜索树",
"99"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"二叉树的中序遍历"
"二叉树的中序遍历",
"94"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"对称二叉树"
"对称二叉树",
"101"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"二叉树的层序遍历"
"二叉树的层序遍历",
"102"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"串联所有单词的子串"
"串联所有单词的子串",
"30"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"分数到小数"
"分数到小数",
"166"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"同构字符串"
"同构字符串",
"205"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"有效的数独"
"有效的数独",
"36"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"缺失的第一个正数"
"缺失的第一个正数",
"41"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"最小覆盖子串"
"最小覆盖子串",
"76"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"字母异位词分组"
"字母异位词分组",
"49"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"单词接龙 II"
"单词接龙 II",
"126"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"单词接龙"
"单词接龙",
"127"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"最长连续序列"
"最长连续序列",
"128"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"组合"
"组合",
"77"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"被围绕的区域"
"被围绕的区域",
"130"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"克隆图"
"克隆图",
"133"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"重新安排行程"
"重新安排行程",
"332"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"课程表"
"课程表",
"207"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"矩阵中的最长递增路径"
"矩阵中的最长递增路径",
"329"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"课程表 II"
"课程表 II",
"210"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"单词搜索"
"单词搜索",
"79"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"路径总和"
"路径总和",
"112"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"路径总和 II"
"路径总和 II",
"113"
]
],
"keywords_forbid": []
......
......@@ -11,7 +11,8 @@
"keywords_must": [
[
"leetcode",
"两数相除"
"两数相除",
"29"
]
],
"keywords_forbid": []
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册