File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# leetcode-problem-picker
22

3-
## Purpose:
4-
This project was a response to my reoccurring question *"Which leetcode problem should I do next?"*
3+
## "Which problem should I do next?"
54

6-
Over time I found that the answer varies, depending on progress, needs, and goals:
7-
1. **Topic Focus**: Narrow down to 1+ subjects e.g. "only do problems related to graphs or DP".
8-
2. **Filtered Lists**: Honing in on questions asked by desired companies. Applies to lists like Blind's Curated 75.
9-
3. **Level Up** (WIP): Deduces user's "skill range" for each topic in order to challenge (but not discourage).
5+
When a problem is too easy, you're wasting your time. Too difficult, and you may soon get discouraged.
6+
7+
During my leetcode journey, I discovered the answer to "which problems should I do next?" depend on goals and progress. I categorized these and gave them names.
8+
1. **Topic Focus**: Narrow down to 1+ subjects e.g. "trees, graphs or DP". Intended for learning and retaining.
9+
2. **Frequently Asked**: Questions from a list, e.g. ones asked by companies or list of Blind's Curated 75.
10+
3. **Level Up** (WIP): Deduces user's "skill range" for each topic in order to challenge appropriately.
1011
4. **Weighted random** (TODO): Weighted towards questions with high like count, greater like/dislike ratio, etc.
1112

1213
## Setup:
@@ -31,10 +32,10 @@ Displays information about a specific problem: Name, difficulty, Acceptance rate
3132
This mode selects and displays a single problem and waits for input:
3233

3334
```
34-
info displays details about problem. problem name, difficulty, acceptance rate
35-
hint displays related topics
36-
y/n,num_errs,time data regarding attempt. See Completed Problems section for more details
37-
easy mark as completed with low completion time, then selects a different problem
35+
info displays details about problem: problem name, difficulty, acceptance rate
36+
hint displays topics related to a solution
37+
y/n,num_errs,time Enter data regarding attempt. See next section for details
38+
easy mark as completed (quickly), then selects a different problem
3839
hard adds to a hard/skipped list. selects a less similar, less challenging problem
3940
revisit [ID] mark problem as one to revisit later
4041
refresh [ID] mark problem as one to "refresh" on later
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def mark_problem(user_data, mark_type, leetcode_id):
7979
problem_to_companies = load_json('problem_to_companies.json')
8080
company_to_problems = load_json('company_to_problems.json')
8181
all_problems = load_json('all_problems.json')
82-
companies = user_data["faang"] + user_data["my_companies]"] # all companies?
82+
my_companies = set(user_data["faang"] + user_data["my_companies]"])
8383

8484
#populate company file w/ maximum of 4 lines (sorted). each line is a comma separated list of problem numbers.
8585
# question: does 1yr,2yr and alltime contain 6mo? does 2yr contain 1yr? I think not?
@@ -100,9 +100,6 @@ def mark_problem(user_data, mark_type, leetcode_id):
100100
problems = pick_problems(user_data, problems=problem_set, topic_list=args.topic_list, k=args.num_problems)
101101
problem_set -= set(problems)
102102

103-
#for company in companies:
104-
# d[company] = get_the_question_set(get_frequencies([company]))
105-
106103
valid_inputs = ["info", "hint", "easy", "hard", "quit", "pause", "break"]
107104
print(f"Other valid inputs: {', '.join(valid_inputs)}")
108105

@@ -119,10 +116,11 @@ def mark_problem(user_data, mark_type, leetcode_id):
119116
# TODO need problem to topic dictionary
120117
raise Exception("Not Implemented Yet")
121118
elif inp == 'info':
122-
company_list = problem_to_companies[leetcode_id]
123119
difficulty_string = "medium difficulty" if problem['Difficulty'] == "Medium" else "considered easy" if problem['Difficulty'] == 'Easy' else problem['Difficulty']
124120
print(f"{leetcode_id} {problem['Name']} is {difficulty_string}: {problem['Acceptance']} of submissions pass")
125-
print(f"{len(company_list)} have asked this question: {', '.join(company_list)}")
121+
company_list = my_companies & set(problem_to_companies[leetcode_id])
122+
company_list_string = f"including: {', '.join(company_list)}" if len(company_list) > 0 else f"including: {','.join(problem_to_companies[leetcode_id][:5])}"
123+
print(f"{len(company_list)} companies have asked this question {company_list_string}")
126124
elif inp == 'pause':
127125
input("Paused. Press Enter to continue the clock\n")
128126
elif inp == 'break':
@@ -132,17 +130,19 @@ def mark_problem(user_data, mark_type, leetcode_id):
132130
mark_completed(leetcode_id, 'yes', '0', '5')
133131
# Replace with new problem not in problems
134132
leetcode_id = pick_problems(user_data, problems=problem_set, topic_list=args.topic_list, k=1)[0]
133+
problem_set.discard(leetcode_id)
135134
start_time = timer()
136135
elif inp == 'hard':
137136
mark_problem(user_data, 'hard', leetcode_id)
138137
leetcode_id = pick_problems(user_data, problems=problem_set, topic_list=args.topic_list, k=1)[0]
138+
problem_set.discard(leetcode_id)
139139
# TODO pick problem with same topic and higher acceptance rate (if possible). If none, default to above line
140140
start_time = timer()
141141
elif inp.startswith('revisit'):
142-
leetcode_id = inp.split(' ')[1] if len(inp.split(' ')) > 0 else leetcode_id
142+
leetcode_id = int(inp.split(' ')[1]) if len(inp.split(' ')) > 0 else leetcode_id
143143
mark_problem(user_data, 'revisit', leetcode_id)
144144
elif inp.startswith('refresh'):
145-
leetcode_id = inp.split(' ')[1] if len(inp.split(' ')) > 0 else leetcode_id
145+
leetcode_id = int(inp.split(' ')[1]) if len(inp.split(' ')) > 0 else leetcode_id
146146
mark_problem(user_data, 'refresh', leetcode_id)
147147
elif inp.startswith('y') or inp.startswith('n'):
148148
# log entry into csv
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
"blind75": [
33
1,3,5,6,8,11,15,19,20,21,22,23,23,31,33,33,39,46,48,49,53,53,54,55,56,57,62,63,70,73,76,78,79,91,98,98,100,102,104,105,121,124,125,127,128,133,139,141,143,152,153,153,190,191,198,200,205,206,207,208,209,211,212,213,217,226,230,235,238,242,268,283,295,297,300,322,338,347,371,373,377,392,417,424,435,560,572,617,647,695,703,779,1011
44
],
5+
"faang": [
6+
"facebook", "amazon", "apple", "", "google"
7+
],
8+
"my_companies": [
9+
],
510
"completed": [
611

712
],

0 commit comments

Comments
 (0)