add flashcard generation tooling and binary search cards

- gen-flashcards.py: auto-generate recognition cards from all problem files
- toolkit/gen-problem-cards.org: 199 auto-generated problem cards
- 5 binary search tool cards (std::binary_search, std::lower_bound, comparison, two-sum pattern, sorting gotcha)
- two-sum.org: add binary search C++ attempt
- lc-org.el: add doom emacs localleader keybinding support
This commit is contained in:
2026-06-08 01:28:25 +08:00
parent c67841fe07
commit e10cc4257d
9 changed files with 2052 additions and 9 deletions
@@ -67,10 +67,27 @@ class Solution:
** TODO C++
#+begin_src cpp :lc-problem 1
#include <algorithm>
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
vector<int> twoSum(vector<int>& nums, int target) {
std::sort(nums.begin(), nums.end());
for (int i=0; i< nums.size(); i++) {
int x = nums[i];
if (x > target) {
return {};
}
// TODO: c++ binary search, i forgot how to do this
int want = target - x
auto it = std::binary_learch(nums.begin() + i + 1, nums.end(), want);
if (it != nums.end() && *it == want) {
int wi = std::distance(nums.begin(), it)
return {i, wi}
}
}
reuturn {};
}
};
#+end_src
#+RESULTS: