Skip to content

Commit d122791

Browse files
authored
feat: add more tags (blind, neetcode, algomaster) (#61)
- add more tags (blind, neetcode, algomaster) - add those problem lists in the .amazonq/plan for easy update later - add available tags to cli help
1 parent 1052a78 commit d122791

File tree

12 files changed

+690
-41
lines changed

12 files changed

+690
-41
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
algo_master_75_tuples = [
2+
(2, "Add Two Numbers"),
3+
(3, "Longest Substring Without Repeating Characters"),
4+
(4, "Median of Two Sorted Arrays"),
5+
(7, "Reverse Integer"),
6+
(11, "Container With Most Water"),
7+
(15, "3Sum"),
8+
(19, "Remove Nth Node From End of List"),
9+
(20, "Valid Parentheses"),
10+
(23, "Merge k Sorted Lists"),
11+
(24, "Swap Nodes in Pairs"),
12+
(25, "Reverse Nodes in k-Group"),
13+
(33, "Search in Rotated Sorted Array"),
14+
(34, "Find First and Last Position of Element in Sorted Array"),
15+
(41, "First Missing Positive"),
16+
(42, "Trapping Rain Water"),
17+
(45, "Jump Game II"),
18+
(46, "Permutations"),
19+
(48, "Rotate Image"),
20+
(49, "Group Anagrams"),
21+
(53, "Maximum Subarray"),
22+
(54, "Spiral Matrix"),
23+
(56, "Merge Intervals"),
24+
(64, "Minimum Path Sum"),
25+
(75, "Sort Colors"),
26+
(76, "Minimum Window Substring"),
27+
(78, "Subsets"),
28+
(84, "Largest Rectangle in Histogram"),
29+
(94, "Binary Tree Inorder Traversal"),
30+
(98, "Validate Binary Search Tree"),
31+
(102, "Binary Tree Level Order Traversal"),
32+
(124, "Binary Tree Maximum Path Sum"),
33+
(127, "Word Ladder"),
34+
(128, "Longest Consecutive Sequence"),
35+
(133, "Clone Graph"),
36+
(139, "Word Break"),
37+
(142, "Linked List Cycle II"),
38+
(144, "Binary Tree Preorder Traversal"),
39+
(145, "Binary Tree Postorder Traversal"),
40+
(146, "LRU Cache"),
41+
(149, "Max Points on a Line"),
42+
(151, "Reverse Words in a String"),
43+
(155, "Min Stack"),
44+
(169, "Majority Element"),
45+
(199, "Binary Tree Right Side View"),
46+
(200, "Number of Islands"),
47+
(208, "Implement Trie (Prefix Tree)"),
48+
(210, "Course Schedule II"),
49+
(212, "Word Search II"),
50+
(213, "House Robber II"),
51+
(230, "Kth Smallest Element in a BST"),
52+
(236, "Lowest Common Ancestor of a Binary Tree"),
53+
(238, "Product of Array Except Self"),
54+
(239, "Sliding Window Maximum"),
55+
(260, "Single Number III"),
56+
(295, "Find Median from Data Stream"),
57+
(297, "Serialize and Deserialize Binary Tree"),
58+
(300, "Longest Increasing Subsequence"),
59+
(322, "Coin Change"),
60+
(329, "Longest Increasing Path in a Matrix"),
61+
(338, "Counting Bits"),
62+
(347, "Top K Frequent Elements"),
63+
(392, "Is Subsequence"),
64+
(416, "Partition Equal Subset Sum"),
65+
(435, "Non-overlapping Intervals"),
66+
(437, "Path Sum III"),
67+
(438, "Find All Anagrams in a String"),
68+
(547, "Number of Provinces"),
69+
(560, "Subarray Sum Equals K"),
70+
(567, "Permutation in String"),
71+
(729, "My Calendar I"),
72+
(785, "Is Graph Bipartite?"),
73+
(787, "Cheapest Flights Within K Stops"),
74+
(994, "Rotting Oranges"),
75+
(1143, "Longest Common Subsequence"),
76+
(1584, "Min Cost to Connect All Points"),
77+
]

.amazonq/plans/blind_75_tuples.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
blind_75_tuples = [
2+
(1, "Two Sum"),
3+
(3, "Longest Substring Without Repeating Characters"),
4+
(5, "Longest Palindromic Substring"),
5+
(11, "Container With Most Water"),
6+
(15, "3Sum"),
7+
(19, "Remove Nth Node From End of List"),
8+
(20, "Valid Parentheses"),
9+
(21, "Merge Two Sorted Lists"),
10+
(23, "Merge k Sorted Lists"),
11+
(33, "Search in Rotated Sorted Array"),
12+
(39, "Combination Sum"),
13+
(48, "Rotate Image"),
14+
(49, "Group Anagrams"),
15+
(53, "Maximum Subarray"),
16+
(54, "Spiral Matrix"),
17+
(55, "Jump Game"),
18+
(56, "Merge Intervals"),
19+
(57, "Insert Interval"),
20+
(62, "Unique Paths"),
21+
(70, "Climbing Stairs"),
22+
(73, "Set Matrix Zeroes"),
23+
(76, "Minimum Window Substring"),
24+
(79, "Word Search"),
25+
(91, "Decode Ways"),
26+
(98, "Validate Binary Search Tree"),
27+
(100, "Same Tree"),
28+
(102, "Binary Tree Level Order Traversal"),
29+
(104, "Maximum Depth of Binary Tree"),
30+
(105, "Construct Binary Tree from Preorder and Inorder Traversal"),
31+
(121, "Best Time to Buy and Sell Stock"),
32+
(124, "Binary Tree Maximum Path Sum"),
33+
(125, "Valid Palindrome"),
34+
(128, "Longest Consecutive Sequence"),
35+
(133, "Clone Graph"),
36+
(139, "Word Break"),
37+
(141, "Linked List Cycle"),
38+
(143, "Reorder List"),
39+
(152, "Maximum Product Subarray"),
40+
(153, "Find Minimum in Rotated Sorted Array"),
41+
(190, "Reverse Bits"),
42+
(191, "Number of 1 Bits"),
43+
(198, "House Robber"),
44+
(200, "Number of Islands"),
45+
(206, "Reverse Linked List"),
46+
(207, "Course Schedule"),
47+
(208, "Implement Trie (Prefix Tree)"),
48+
(211, "Design Add and Search Words Data Structure"),
49+
(212, "Word Search II"),
50+
(213, "House Robber II"),
51+
(217, "Contains Duplicate"),
52+
(226, "Invert Binary Tree"),
53+
(230, "Kth Smallest Element in a BST"),
54+
(235, "Lowest Common Ancestor of a Binary Search Tree"),
55+
(238, "Product of Array Except Self"),
56+
(242, "Valid Anagram"),
57+
(252, "Meeting Rooms"),
58+
(253, "Meeting Rooms II"),
59+
(261, "Graph Valid Tree"),
60+
(268, "Missing Number"),
61+
(269, "Alien Dictionary"),
62+
(271, "Encode and Decode Strings"),
63+
(295, "Find Median from Data Stream"),
64+
(297, "Serialize and Deserialize Binary Tree"),
65+
(300, "Longest Increasing Subsequence"),
66+
(322, "Coin Change"),
67+
(323, "Number of Connected Components in an Undirected Graph"),
68+
(338, "Counting Bits"),
69+
(347, "Top K Frequent Elements"),
70+
(371, "Sum of Two Integers"),
71+
(417, "Pacific Atlantic Water Flow"),
72+
(424, "Longest Repeating Character Replacement"),
73+
(435, "Non-overlapping Intervals"),
74+
(572, "Subtree of Another Tree"),
75+
(647, "Palindromic Substrings"),
76+
(1143, "Longest Common Subsequence"),
77+
]
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# TODO: temporary use only while completing ongoing list
2+
3+
import json
4+
import sys
5+
from pathlib import Path
6+
7+
# Import the tuple lists
8+
sys.path.append(str(Path(__file__).parent.parent.parent))
9+
from algo_master_75_tuples import algo_master_75_tuples
10+
from blind_75_tuples import blind_75_tuples
11+
from neetcode_150_tuples import neetcode_150_tuples
12+
13+
14+
def get_existing_problems():
15+
"""Get problem numbers from existing JSON files."""
16+
json_dir = Path(__file__).parent.parent.parent / "leetcode_py/cli/resources/leetcode/json/problems"
17+
existing_problems = set()
18+
19+
for json_file in json_dir.glob("*.json"):
20+
try:
21+
with open(json_file, "r") as f:
22+
data = json.load(f)
23+
problem_number = int(data.get("problem_number", 0))
24+
if problem_number > 0:
25+
existing_problems.add(problem_number)
26+
except (json.JSONDecodeError, ValueError, KeyError):
27+
continue
28+
29+
return existing_problems
30+
31+
32+
def check_problem_list(name, problem_tuples, existing_problems):
33+
"""Check how many problems from a list are available."""
34+
problem_numbers = {num for num, _ in problem_tuples}
35+
have = problem_numbers & existing_problems
36+
missing = problem_numbers - existing_problems
37+
38+
print(f"\n=== {name} ===")
39+
print(f"Total problems: {len(problem_numbers)}")
40+
print(f"Problems you have: {len(have)} ({len(have)/len(problem_numbers)*100:.1f}%)")
41+
print(f"Problems missing: {len(missing)} ({len(missing)/len(problem_numbers)*100:.1f}%)")
42+
43+
if missing:
44+
print(f"Missing problems: {sorted(missing)}")
45+
46+
return have, missing
47+
48+
49+
def main():
50+
existing = get_existing_problems()
51+
print(f"Total existing problems in JSON: {len(existing)}")
52+
53+
# Check each list
54+
blind_have, blind_missing = check_problem_list("BLIND 75", blind_75_tuples, existing)
55+
neetcode_have, neetcode_missing = check_problem_list("NEETCODE 150", neetcode_150_tuples, existing)
56+
algo_have, algo_missing = check_problem_list("ALGO MASTER 75", algo_master_75_tuples, existing)
57+
58+
# Summary
59+
print("\n=== SUMMARY ===")
60+
print(f"Blind 75: {len(blind_have)}/75 ({len(blind_have)/75*100:.1f}%)")
61+
print(f"NeetCode 150: {len(neetcode_have)}/150 ({len(neetcode_have)/150*100:.1f}%)")
62+
print(f"Algo Master 75: {len(algo_have)}/75 ({len(algo_have)/75*100:.1f}%)")
63+
64+
65+
if __name__ == "__main__":
66+
main()

.amazonq/plans/export_tags.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# TODO: temporary use only while completing ongoing list
2+
3+
import json
4+
import sys
5+
from pathlib import Path
6+
7+
# Import the tuple lists
8+
sys.path.append(str(Path(__file__).parent.parent.parent))
9+
from algo_master_75_tuples import algo_master_75_tuples
10+
from neetcode_150_tuples import neetcode_150_tuples
11+
12+
13+
def get_existing_problems():
14+
"""Get problem numbers and names from existing JSON files."""
15+
json_dir = Path(__file__).parent.parent.parent / "leetcode_py/cli/resources/leetcode/json/problems"
16+
existing_problems = {}
17+
18+
for json_file in json_dir.glob("*.json"):
19+
try:
20+
with open(json_file, "r") as f:
21+
data = json.load(f)
22+
problem_number = int(data.get("problem_number", 0))
23+
if problem_number > 0:
24+
existing_problems[problem_number] = json_file.stem
25+
except (json.JSONDecodeError, ValueError, KeyError):
26+
continue
27+
28+
return existing_problems
29+
30+
31+
def get_tag_problems(problem_tuples, existing_problems):
32+
"""Get problem names for existing problems from a tuple list."""
33+
problem_names = []
34+
for num, _ in problem_tuples:
35+
if num in existing_problems:
36+
problem_names.append(existing_problems[num])
37+
return sorted(problem_names)
38+
39+
40+
def export_tags():
41+
"""Export tags.json5 format for the three problem lists."""
42+
existing = get_existing_problems()
43+
44+
# Get problem names for each list
45+
neetcode_150_names = get_tag_problems(neetcode_150_tuples, existing)
46+
algo_master_75_names = get_tag_problems(algo_master_75_tuples, existing)
47+
48+
# Generate tags.json5 content
49+
content = """{\n"""
50+
51+
# NeetCode 150
52+
content += f" // NeetCode 150 - {len(neetcode_150_names)} problems\n"
53+
content += ' "neetcode-150": [\n'
54+
for name in neetcode_150_names:
55+
content += f' "{name}",\n'
56+
content += " ],\n\n"
57+
58+
# Algo Master 75
59+
content += f" // Algo Master 75 - {len(algo_master_75_names)} problems\n"
60+
content += ' "algo-master-75": [\n'
61+
for name in algo_master_75_names:
62+
content += f' "{name}",\n'
63+
content += " ],\n\n"
64+
65+
# Test tag
66+
content += " // Test tag for development and testing\n"
67+
content += ' test: ["binary_search", "two_sum", "valid_palindrome"],\n'
68+
content += "}\n"
69+
70+
# Write to file
71+
output_file = Path(__file__).parent / "new_tags.json5"
72+
with open(output_file, "w") as f:
73+
f.write(content)
74+
75+
print(f"Exported tags to {output_file}")
76+
print(f"NeetCode 150: {len(neetcode_150_names)} problems")
77+
print(f"Algo Master 75: {len(algo_master_75_names)} problems")
78+
79+
80+
if __name__ == "__main__":
81+
export_tags()

0 commit comments

Comments
 (0)