1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-04-18 08:39:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
程序员小墨 2022-03-29 12:55:24 +08:00
parent 2b0511d272
commit b84ae535b7
3973 changed files with 51044 additions and 105065 deletions
get.batleetcode-cn.py
leetcode-cn
leetcode.py
leetcode
[en]json2-problemset.jsonorigin-data.json
originData
01-matrix.json1-bit-and-2-bit-characters.json132-pattern.json2-keys-keyboard.json24-game.json3sum-closest.json3sum-with-multiplicity.json3sum.json4sum-ii.json4sum.json[no content]3sum-smaller.json[no content]4-keys-keyboard.json[no content]accepted-candidates-from-the-interviews.json[no content]account-balance.json[no content]active-businesses.json[no content]active-users.json[no content]activity-participants.json[no content]ad-free-sessions.json[no content]add-bold-tag-in-string.json[no content]add-two-polynomials-represented-as-linked-lists.json[no content]ads-performance.json[no content]alien-dictionary.json[no content]all-paths-from-source-lead-to-destination.json[no content]all-people-report-to-the-given-manager.json[no content]all-the-pairs-with-the-maximum-number-of-common-followers.json[no content]all-valid-triplets-that-can-represent-a-country.json[no content]amount-of-new-area-painted-each-day.json[no content]analyze-user-website-visit-pattern.json[no content]android-unlock-patterns.json[no content]apples-oranges.json[no content]armstrong-number.json[no content]array-transformation.json[no content]article-views-ii.json[no content]average-height-of-buildings-in-each-segment.json[no content]average-salary-departments-vs-company.json[no content]average-selling-price.json[no content]average-time-of-process-per-machine.json[no content]bank-account-summary.json[no content]basic-calculator-iii.json[no content]before-and-after-puzzle.json[no content]best-meeting-point.json[no content]biggest-single-number.json[no content]biggest-window-between-visits.json[no content]binary-search-tree-iterator-ii.json[no content]binary-searchable-numbers-in-an-unsorted-array.json[no content]binary-tree-longest-consecutive-sequence-ii.json[no content]binary-tree-longest-consecutive-sequence.json[no content]binary-tree-upside-down.json[no content]binary-tree-vertical-order-traversal.json[no content]bold-words-in-string.json[no content]bomb-enemy.json[no content]boundary-of-binary-tree.json[no content]brace-expansion.json[no content]brightest-position-on-street.json[no content]build-binary-expression-tree-from-infix-expression.json[no content]build-the-equation.json[no content]buildings-with-an-ocean-view.json[no content]calculate-salaries.json[no content]campus-bikes-ii.json[no content]campus-bikes.json[no content]candy-crush.json[no content]change-the-root-of-a-binary-tree.json[no content]check-if-a-number-is-majority-element-in-a-sorted-array.json[no content]check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree.json[no content]check-if-string-is-decomposable-into-value-equal-substrings.json[no content]check-if-two-expression-trees-are-equivalent.json[no content]checking-existence-of-edge-length-limited-paths-ii.json[no content]choose-numbers-from-two-arrays-in-range.json[no content]clone-binary-tree-with-random-pointer.json[no content]clone-n-ary-tree.json[no content]closest-binary-search-tree-value-ii.json[no content]closest-binary-search-tree-value.json[no content]closest-leaf-in-a-binary-tree.json[no content]coin-path.json[no content]confirmation-rate.json[no content]confusing-number-ii.json[no content]confusing-number.json[no content]connecting-cities-with-minimum-cost.json[no content]consecutive-available-seats.json[no content]construct-binary-tree-from-string.json[no content]convert-binary-search-tree-to-sorted-doubly-linked-list.json[no content]convert-date-format.json[no content]convex-polygon.json[no content]correct-a-binary-tree.json[no content]count-apples-and-oranges.json[no content]count-nodes-equal-to-sum-of-descendants.json[no content]count-pairs-in-two-arrays.json[no content]count-pairs-of-equal-substrings-with-minimum-difference.json[no content]count-salary-categories.json[no content]count-student-number-in-departments.json[no content]count-subarrays-with-more-ones-than-zeros.json[no content]count-substrings-with-only-one-distinct-letter.json[no content]count-the-number-of-experiments.json

@ -8,5 +8,6 @@ echo "
pause
git add .
git commit -m "update"
git gc
git push
pause

@ -34,7 +34,6 @@ def parse_proble_set(problemSet):
continue
def construct_url(problemTitle):
# url = "https://leetcode-cn.com/problems/"+ problemTitle + "/description/"
url = "https://leetcode-cn.com/problems/"+ problemTitle + "/"
# print(url)
get_proble_content(url,problemTitle)
@ -120,11 +119,11 @@ def saveJSON(data, filename):
def main():
url = "https://leetcode-cn.com/api/problems/all/"
html = json.loads(get_proble_set(url))
problemset = html["stat_status_pairs"]
saveJSON(html, "[cn]json1-origin-data.json")
saveJSON(problemset, "[cn]json2-problemset.json")
saveJSON(html, "origin-data.json")
# problemset = json.load(open("[cn]json2-problemset.json", 'r', encoding='utf-8'))
# html = json.load(open("origin-data.json", 'r', encoding='utf-8'))
problemset = html["stat_status_pairs"]
parse_proble_set(problemset)

File diff suppressed because it is too large Load Diff

@ -22,7 +22,7 @@ def parse_proble_set(problemSet):
for i in range(len(problemSet)):
# for i in range(930, len(problemSet)):
title = problemSet[i]["stat"]["question__title_slug"]
if os.path.exists("[no content]{}.json".format(title)) or os.path.exists("{}.json".format(title)):
if os.path.exists("originData/[no content]{}.json".format(title)) or os.path.exists("originData/{}.json".format(title)):
print(i, "has been parsed.")
# print("The question has been parsed: {}".format(title))
continue
@ -31,7 +31,6 @@ def parse_proble_set(problemSet):
time.sleep(1)
t =threading.Thread(target=construct_url,args=(title,))
t.start()
print(i, "is done.")
continue
@ -85,13 +84,13 @@ def get_proble_content(problemUrl,title):
response = requests.post(url,data = dumpJsonData, headers = headers,cookies = cookies)
dictInfo = json.loads(response.text)
if dictInfo["data"]["question"].get("content") is not None:
saveJSON(dictInfo, title + ".json")
saveJSON(dictInfo, "originData/" + title + ".json")
content = dictInfo["data"]["question"]["content"]
save_problem(title,content)
save_problem("problem/" + title, content)
# soup = BeautifulSoup(content, 'lxml')
# save_problem(title,soup.prettify())
else:
saveJSON(dictInfo, "[no content]" + title + ".json")
saveJSON(dictInfo, "originData/[no content]" + title + ".json")
# print("no content")
except Exception as e:
print("[error] ", e, problemUrl)
@ -103,11 +102,11 @@ def saveJSON(data, filename):
def main():
url = "https://leetcode.com/api/problems/all/"
html = json.loads(get_proble_set(url))
problemset = html["stat_status_pairs"]
saveJSON(html, "[en]json1-origin-data.json")
saveJSON(problemset, "[en]json2-problemset.json")
saveJSON(html, "origin-data.json")
# problemset = json.load(open("[en]json2-problemset.json", 'r', encoding='utf-8'))
# html = json.load(open("origin-data.json", 'r', encoding='utf-8'))
problemset = html["stat_status_pairs"]
parse_proble_set(problemset)
@ -115,5 +114,9 @@ if __name__=='__main__':
folderName = "leetcode"
if not os.path.exists(folderName):
os.mkdir(folderName)
if not os.path.exists(folderName + "/originData"):
os.mkdir(folderName + "/originData")
if not os.path.exists(folderName + "/problem"):
os.mkdir(folderName + "/problem")
os.chdir(folderName)
main()

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More