Skip to content

Commit

Permalink
add: arg 参数搜素
Browse files Browse the repository at this point in the history
Signed-off-by: 胡金栋 <[email protected]>
  • Loading branch information
JamesHopbourn committed Nov 8, 2023
1 parent 00ad21c commit 758804f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions leetcode.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import re
import sys
import json

def camel_to_snake(camel_case_string):
snake_case_string = re.sub(r'([A-Z])', r'-\1', camel_case_string)
return snake_case_string.lstrip('-').lower()

data = open('result.json').read()
data = json.loads(data)
result=[]
result = []
for item in data:
if sys.argv[1].lower() not in item["title"].lower():
# ValidAnagram
if sys.argv[1].isalpha() and camel_to_snake(sys.argv[1]) == item["arg"]:
pass
elif sys.argv[1].lower() not in item["title"].lower():
continue
if sys.argv[2].lower() == "":
item["arg"] = f"https://leetcode.cn/problems/{item['arg']}/description/"
Expand Down

0 comments on commit 758804f

Please sign in to comment.