Skip to content

Commit 7a68097

Browse files
committed
feat: Neetcode75 question list
1 parent e59b8e1 commit 7a68097

File tree

3 files changed

+126
-1
lines changed

3 files changed

+126
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ All notable changes to this project will be documented in this file.
2222

2323
- Invalidate questions cache through `userSessionProgress`
2424

25+
## [0.2.1] - [Unreleased]
26+
27+
### Added
28+
29+
- Neetcode 75 question list.
30+
2531
## [0.2.0] - 2023-07-30
2632

2733
### Added

src/app_ui/widgets/question_list.rs

Lines changed: 115 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,40 @@ impl QuestionListWidget {
550550
IndexSet::new(),
551551
)))
552552
}
553+
554+
fn process_neetcode_75_questions(&mut self, all_questions: impl Iterator<Item = Question>) {
555+
let nc75slugset: HashMap<&str, usize> = HashMap::from_iter(
556+
NEETCODE_75
557+
.into_iter()
558+
.zip(0..75)
559+
.collect::<Vec<(&str, usize)>>(),
560+
);
561+
562+
let mut nc75questions: Vec<Option<Question>> = vec![None; 75];
563+
for question in all_questions {
564+
let title = question
565+
.question
566+
.borrow()
567+
.title_slug
568+
.as_ref()
569+
.unwrap()
570+
.clone();
571+
if nc75slugset.contains_key(&title.as_str()) {
572+
nc75questions[*nc75slugset.get(title.as_str()).unwrap()] = Some(question.clone());
573+
}
574+
}
575+
self.all_questions.insert(
576+
Rc::new(TopicTagModel {
577+
id: "neetcode-75".to_string(),
578+
name: Some("Neetcode 75".to_string()),
579+
slug: Some("neetcode-75".to_string()),
580+
}),
581+
nc75questions
582+
.into_iter()
583+
.map(|v| v.unwrap())
584+
.collect::<Vec<_>>(),
585+
);
586+
}
553587
}
554588

555589
impl super::Widget for QuestionListWidget {
@@ -734,6 +768,8 @@ impl super::Widget for QuestionListWidget {
734768
})
735769
.collect::<HashMap<_, _>>();
736770

771+
let all_question_list = question_set.values().cloned();
772+
737773
let map_iter = content.into_iter().map(|v| {
738774
(
739775
Rc::new(v.0),
@@ -742,11 +778,11 @@ impl super::Widget for QuestionListWidget {
742778
.collect::<Vec<_>>(),
743779
)
744780
});
745-
746781
self.all_questions.extend(map_iter);
747782
for ql in &mut self.all_questions.values_mut() {
748783
ql.sort_unstable()
749784
}
785+
self.process_neetcode_75_questions(all_question_list);
750786
self.get_notification_queue()
751787
.push_back(Notification::Questions(NotifContent::new(
752788
WidgetName::QuestionList,
@@ -1023,3 +1059,81 @@ impl super::Widget for QuestionListWidget {
10231059
&mut self.common_state.notification_queue
10241060
}
10251061
}
1062+
1063+
const NEETCODE_75: [&str; 75] = [
1064+
"contains-duplicate",
1065+
"valid-anagram",
1066+
"two-sum",
1067+
"group-anagrams",
1068+
"top-k-frequent-elements",
1069+
"product-of-array-except-self",
1070+
"encode-and-decode-strings",
1071+
"longest-consecutive-sequence",
1072+
"valid-palindrome",
1073+
"3sum",
1074+
"container-with-most-water",
1075+
"best-time-to-buy-and-sell-stock",
1076+
"longest-substring-without-repeating-characters",
1077+
"longest-repeating-character-replacement",
1078+
"minimum-window-substring",
1079+
"valid-parentheses",
1080+
"find-minimum-in-rotated-sorted-array",
1081+
"search-in-rotated-sorted-array",
1082+
"reverse-linked-list",
1083+
"merge-two-sorted-lists",
1084+
"reorder-list",
1085+
"remove-nth-node-from-end-of-list",
1086+
"linked-list-cycle",
1087+
"merge-k-sorted-lists",
1088+
"invert-binary-tree",
1089+
"maximum-depth-of-binary-tree",
1090+
"same-tree",
1091+
"subtree-of-another-tree",
1092+
"lowest-common-ancestor-of-a-binary-search-tree",
1093+
"binary-tree-level-order-traversal",
1094+
"validate-binary-search-tree",
1095+
"kth-smallest-element-in-a-bst",
1096+
"construct-binary-tree-from-preorder-and-inorder-traversal",
1097+
"binary-tree-maximum-path-sum",
1098+
"serialize-and-deserialize-binary-tree",
1099+
"implement-trie-prefix-tree",
1100+
"design-add-and-search-words-data-structure",
1101+
"word-search-ii",
1102+
"find-median-from-data-stream",
1103+
"combination-sum",
1104+
"word-search",
1105+
"number-of-islands",
1106+
"clone-graph",
1107+
"pacific-atlantic-water-flow",
1108+
"course-schedule",
1109+
"number-of-connected-components-in-an-undirected-graph",
1110+
"graph-valid-tree",
1111+
"alien-dictionary",
1112+
"climbing-stairs",
1113+
"house-robber",
1114+
"house-robber-ii",
1115+
"longest-palindromic-substring",
1116+
"palindromic-substrings",
1117+
"decode-ways",
1118+
"coin-change",
1119+
"maximum-product-subarray",
1120+
"word-break",
1121+
"longest-increasing-subsequence",
1122+
"unique-paths",
1123+
"longest-common-subsequence",
1124+
"maximum-subarray",
1125+
"jump-game",
1126+
"insert-interval",
1127+
"merge-intervals",
1128+
"non-overlapping-intervals",
1129+
"meeting-rooms",
1130+
"meeting-rooms-ii",
1131+
"rotate-image",
1132+
"spiral-matrix",
1133+
"set-matrix-zeroes",
1134+
"number-of-1-bits",
1135+
"counting-bits",
1136+
"reverse-bits",
1137+
"missing-number",
1138+
"sum-of-two-integers",
1139+
];

src/app_ui/widgets/topic_list.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ impl Widget for TopicTagListWidget {
128128
id: "all".to_owned(),
129129
slug: Some("all".to_owned()),
130130
});
131+
self.topics.add_item(TopicTagModel {
132+
id: "neetcode-75".to_string(),
133+
name: Some("Neetcode 75".to_string()),
134+
slug: Some("neetcode-75".to_string()),
135+
});
131136
for tt in content {
132137
self.topics.add_item(tt)
133138
}

0 commit comments

Comments
 (0)