摘要: e.g. template <class Type, typename ...Args> Type *allocate(Args &&...args) { void *mem = this->get_available_mem(sizeof(Type)); Type *new_ptr = reint 阅读全文
posted @ 2021-01-31 21:26 linsinan1995 阅读(57) 评论(0) 推荐(0)
摘要: segments(runtime) & sections(link time) A segment points to an absolute address in the memory, and specify how many bytes are contained in that segmen 阅读全文
posted @ 2021-01-04 22:49 linsinan1995 阅读(194) 评论(0) 推荐(0)
摘要: 比较有意思的回溯题, 记录一下 class Solution { vector<string> res {}; public: vector<string> generateParenthesis(int n) { string s; // 0 -> number of open parenth b 阅读全文
posted @ 2020-11-16 23:41 linsinan1995 阅读(61) 评论(0) 推荐(0)
摘要: priority_queue模板声明类名 → 可用decltype 把lambda表达式当作参数来初始化 https://en.cppreference.com/w/cpp/container/priority_queue/priority_queue 阅读全文
posted @ 2020-10-20 23:45 linsinan1995 阅读(950) 评论(0) 推荐(0)
摘要: path sum I DFS+判断 https://leetcode.com/problems/path-sum/ class Solution { public: bool hasPathSum(TreeNode* root, int sum) { if (!root) return false; 阅读全文
posted @ 2020-10-16 04:38 linsinan1995 阅读(49) 评论(0) 推荐(0)
摘要: 1.子类内存模型 父类+子类多的variable 2.virtual → 函数地址晚绑定,运行时可以再动态决定 3.编译时,如果类有virtual,编译器会给该类提供一个1维的虚表vtable。 编译器给每个对象(注意是对象)一个vptr, 这个指针指向了对象当前对应类的虚表,这样调用时候就能找到对 阅读全文
posted @ 2020-10-10 05:30 linsinan1995 阅读(66) 评论(0) 推荐(0)
摘要: 1.图表示 Adjacent list vector<int> adj[N] weighted graph vector<pair<int,int>> adj[N]; adjacent matrix int adj[N][N]; edge list vector<pair<int, int>> ed 阅读全文
posted @ 2020-09-19 22:59 linsinan1995 阅读(149) 评论(0) 推荐(0)
摘要: 1.部分集合/有序数组操作 C++的set操作其实只是代表有序集合。 对比操作 set_difference set_intersection set_union set_symmetric_difference include 合并操作 merge implace_merge #include < 阅读全文
posted @ 2020-09-12 05:55 linsinan1995 阅读(808) 评论(0) 推荐(0)
摘要: 老是写不好二分,特此学习总结一下。 lower_bound 和 upper_bound 这两个函数基本上能替代手写的二分查找,但是千万别弄错俩函数的作用。 lower_bound 返回数组中第一个不小于目标值的元素的iterator,(第一个>=target的数) upper_bound 返回数组中 阅读全文
posted @ 2020-09-06 19:20 linsinan1995 阅读(486) 评论(0) 推荐(0)
摘要: 最大最小值DP Choose minimum (maximum) path among all possible paths before the current state, then add value for the current state. routes[i] = min(routes[ 阅读全文
posted @ 2020-08-25 20:29 linsinan1995 阅读(164) 评论(0) 推荐(0)