Skip to content

Commit 30b0e25

Browse files
committed
Add frequency and sorting
1 parent cea3713 commit 30b0e25

File tree

4 files changed

+263
-45
lines changed

4 files changed

+263
-45
lines changed

autoload/leetcode.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ def _get_category_problems(category):
180180
'ac_rate': p['stat']['total_acs'] / p['stat']['total_submitted'],
181181
'level': _level_to_name(p['difficulty']['level']),
182182
'favor': p['is_favor'],
183-
'category': content['category_slug']}
183+
'category': content['category_slug'],
184+
'frequency': p['frequency']}
184185
problems.append(problem)
185186
return problems
186187

@@ -626,6 +627,7 @@ def get_problems_of_topic(topic_slug):
626627
return None
627628

628629
topic_tag = res.json()['data']['topicTag']
630+
id_to_frequency_map = json.loads(topic_tag['frequencies'])
629631

630632
def process_problem(p):
631633
stats = json.loads(p['stats'])
@@ -639,7 +641,8 @@ def process_problem(p):
639641
'paid_only': p['isPaidOnly'],
640642
'ac_rate': stats['totalAcceptedRaw'] / stats['totalSubmissionRaw'],
641643
'level': p['difficulty'],
642-
'favor': False}
644+
'favor': False,
645+
'frequency': id_to_frequency_map[p['questionId']]}
643646

644647
return {
645648
'topic_name': topic_tag['name'],
@@ -727,6 +730,7 @@ def get_problems_of_company(company_slug):
727730
return None
728731

729732
company_tag = res.json()['data']['companyTag']
733+
id_to_frequency_map = json.loads(company_tag['frequencies'])
730734

731735
def process_problem(p):
732736
stats = json.loads(p['stats'])
@@ -740,7 +744,8 @@ def process_problem(p):
740744
'paid_only': p['isPaidOnly'],
741745
'ac_rate': stats['totalAcceptedRaw'] / stats['totalSubmissionRaw'],
742746
'level': p['difficulty'],
743-
'favor': False}
747+
'favor': False,
748+
'frequencies': id_to_frequency_map[p['questionId']][4:]}
744749

745750
return {
746751
'company_name': company_tag['name'],

0 commit comments

Comments
 (0)