Skip to content

Commit 8630d43

Browse files
committed
feat: [experimental] add difficulty and solutions
1 parent 6936ebc commit 8630d43

File tree

7 files changed

+3560
-1364
lines changed

7 files changed

+3560
-1364
lines changed

data-gen/.ipynb_checkpoints/leetcode_scraper-checkpoint.ipynb

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"cell_type": "code",
55
"execution_count": null,
6-
"id": "90903826",
6+
"id": "abeb0073",
77
"metadata": {},
88
"outputs": [],
99
"source": [
@@ -18,7 +18,7 @@
1818
{
1919
"cell_type": "code",
2020
"execution_count": null,
21-
"id": "8acd2701",
21+
"id": "c2b6ff54",
2222
"metadata": {},
2323
"outputs": [],
2424
"source": [
@@ -32,7 +32,7 @@
3232
{
3333
"cell_type": "code",
3434
"execution_count": null,
35-
"id": "831d782e",
35+
"id": "a9bacba8",
3636
"metadata": {},
3737
"outputs": [],
3838
"source": [
@@ -118,10 +118,11 @@
118118
{
119119
"cell_type": "code",
120120
"execution_count": null,
121-
"id": "cc9ecf71",
121+
"id": "8eedcca9",
122122
"metadata": {},
123123
"outputs": [],
124124
"source": [
125+
"# note: this cell takes around 1 hour to finish\n",
125126
"# go through questions in the leetcode question list\n",
126127
"leetcode_problems = pd.read_csv('../data/leetcode_problems.csv')\n",
127128
"problems_companies_info = get_problems_companies_info(leetcode_problems)\n",
@@ -131,7 +132,7 @@
131132
{
132133
"cell_type": "code",
133134
"execution_count": null,
134-
"id": "d570a4aa",
135+
"id": "30c80380",
135136
"metadata": {},
136137
"outputs": [],
137138
"source": []

data-gen/leetcode_scraper.ipynb

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"cell_type": "code",
55
"execution_count": null,
6-
"id": "90903826",
6+
"id": "abeb0073",
77
"metadata": {},
88
"outputs": [],
99
"source": [
@@ -18,7 +18,7 @@
1818
{
1919
"cell_type": "code",
2020
"execution_count": null,
21-
"id": "8acd2701",
21+
"id": "c2b6ff54",
2222
"metadata": {},
2323
"outputs": [],
2424
"source": [
@@ -32,7 +32,7 @@
3232
{
3333
"cell_type": "code",
3434
"execution_count": null,
35-
"id": "831d782e",
35+
"id": "a9bacba8",
3636
"metadata": {},
3737
"outputs": [],
3838
"source": [
@@ -118,10 +118,11 @@
118118
{
119119
"cell_type": "code",
120120
"execution_count": null,
121-
"id": "cc9ecf71",
121+
"id": "8eedcca9",
122122
"metadata": {},
123123
"outputs": [],
124124
"source": [
125+
"# note: this cell takes around 1 hour to finish\n",
125126
"# go through questions in the leetcode question list\n",
126127
"leetcode_problems = pd.read_csv('../data/leetcode_problems.csv')\n",
127128
"problems_companies_info = get_problems_companies_info(leetcode_problems)\n",
@@ -131,7 +132,7 @@
131132
{
132133
"cell_type": "code",
133134
"execution_count": null,
134-
"id": "d570a4aa",
135+
"id": "30c80380",
135136
"metadata": {},
136137
"outputs": [],
137138
"source": []

data-gen/parse_readme.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44

55
parsed_list = []
66
df = md_to_df('../data/leetcode_repo_readme.md')
7-
87
for _, row in df.iterrows():
98
name_and_link = row['Title']
9+
difficulty = row['Difficulty']
10+
solution = row['Solutions'].replace('..', 'https://github.com/fishercoder1534/Leetcode/blob')
1011
m = re.search(r'\[(.*)\]\((.*)\)', name_and_link)
1112
name = m[1]
1213
link = m[2]
13-
parsed_list.append((name, link, ))
14+
parsed_list.append((name, link, difficulty, solution, ))
1415

15-
parsed_df = pd.DataFrame(parsed_list, columns=['name', 'link'])
16+
parsed_df = pd.DataFrame(parsed_list, columns=['name', 'link', 'difficulty', 'solution'])
1617
parsed_df.to_csv('../data/leetcode_problems.csv', index=False)
1718

1819

data-gen/transform_data.ipynb

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "a801754c",
5+
"id": "75f28a50",
66
"metadata": {},
77
"source": [
88
"## Generate pivot wider CSV"
@@ -11,7 +11,7 @@
1111
{
1212
"cell_type": "code",
1313
"execution_count": 2,
14-
"id": "742dffb8",
14+
"id": "5332f87a",
1515
"metadata": {},
1616
"outputs": [],
1717
"source": [
@@ -21,7 +21,7 @@
2121
{
2222
"cell_type": "code",
2323
"execution_count": 53,
24-
"id": "ea4a7917",
24+
"id": "b4ae5a29",
2525
"metadata": {},
2626
"outputs": [],
2727
"source": [
@@ -33,7 +33,7 @@
3333
},
3434
{
3535
"cell_type": "markdown",
36-
"id": "9ba1b2b6",
36+
"id": "72e54b4c",
3737
"metadata": {},
3838
"source": [
3939
"## Generate CSV for each company"
@@ -42,7 +42,7 @@
4242
{
4343
"cell_type": "code",
4444
"execution_count": 62,
45-
"id": "d08c2d89",
45+
"id": "daed41c6",
4646
"metadata": {},
4747
"outputs": [],
4848
"source": [
@@ -57,7 +57,7 @@
5757
{
5858
"cell_type": "code",
5959
"execution_count": null,
60-
"id": "2a32435c",
60+
"id": "9649af13",
6161
"metadata": {},
6262
"outputs": [],
6363
"source": []

0 commit comments

Comments
 (0)