使用protobuf生成各大厂的开放平台接口
摘要:
# protoc-gen-go_api 一款用protobuf文件生成go的http调用代码。具体代码见 [protoc-gen-go_api](https://github.com/dev-openapi/protoc-gen-go_api) ## 安装 ```bash go install gi
携程apollo-go客户端
摘要:
背景 最近在用携程的apollo配置中心, 使用的是go语言客户端,官方推荐的agollo,由于apollo的properties格式的配置文件,返回的都是string类型,所以当配置了一个非string类型的时候,是在获取动态配置的时候,才解析,这对于动态配置,读多写少的场景,显然是不太合适的,所
LeetCode第K最值
摘要:
## Kth Kth Largest Element in an Array [LeetCode](https://leetcode.com/problems/kth-largest-element-in-an-array)/[力扣](https://leetcode-cn.com/problems
LeetCode二分搜索
摘要:
## Search in Rotated Sorted Array [LeetCode](https://leetcode.com/problems/search-in-rotated-sorted-array)/[力扣](https://leetcode-cn.com/problems/searc
LeetCode双堆问题
摘要:
## Find Median from Data Stream [LeetCode](https://leetcode.com/problems/find-median-from-data-stream/)/[力扣](https://leetcode-cn.com/problems/find-med
LeetCode回溯算法
摘要:
Letter Combinations of a Phone Number LeetCode/力扣 vector<string> letterCombinations(string digits) { if(digits.length() == 0) return {}; map<char,stri
LeetCode深度优先搜索
摘要:
Validate Binary Search Tree LeetCode/力扣 递归 bool isValidBST(TreeNode* root) { double lower = DBL_MIN; double upper = DBL_MAX; return helper(root, lower
LeetCode广度优先搜索
摘要:
Binary Tree Level Order Traversal LeetCode/力扣 递归 void levelOrderHelper(vector<vector<int>> &res, int level, TreeNode *root) { if (root == NULL) return
LeetCode链表翻转
摘要:
Swap Nodes in Pairs LeetCode/力扣 递归 交换之后,直接交换下一个节点 ListNode* swapPairs(ListNode* head) { if(head && head->next) { swap(head->val, head->next->val); swa
LeetCode区间合并
摘要:
Merge Intervals LeetCode/力扣 先排序 然后遍历组合 如果满足合并条件, 当前区间的末尾(两个取大的) vector<vector<int>> merge(vector<vector<int>>& intervals) { sort(intervals.begin(), in
LeetCode快慢指针
摘要:
Add Two Numbers LeetCode/力扣 模拟两个数相加 用一个数表示进位 ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) { ListNode *t1 = l1, *t2 = l2; int n1 = 0, n2 = 0, c
LeetCode双指针
摘要:
Two Sum LeetCode/力扣 先排序 排序完,用两个指针分别指向第一个和最后一个 根据和,分别移动前后指针 上述方法需要额外保存排序前的位置,所以可解,但不推荐,现给出排序好的解法(不是当前题目解法) vector<int> twoSum(vector<int>& nums, int ta
LeetCode滑动窗口
摘要:
Longest Substring Without Repeating Characters LeetCode/力扣 用一个子串保存当前的窗口,查找下一个字符在子串的位置 如果为-1,则将字符加入子串,即窗口右移动 如果不为-1, 将窗口左边移动到子串中最后一个字符的下一个字符所在位置 int le
LeetCode数组
摘要:
LeetCode分类刷题系列 First Missing Positive LeetCode/力扣 用一个数组保存0~n是否有数,假设都为1 遍历数组,如果出现了,设为0,大于n或者小于0,忽略 最后遍历一遍就是结果,如果跑到最后,直接输出n+1 int firstMissingPositive(v
页面置换算法
摘要:
如果进程运行时需要的内存很大时,物理内存不足以载入所有的内存,那么久需要将进程的数据保存到磁盘中,然后在需要的时候,把其加载到内存,但是物理内存已经满了,所以需要把一些内存保存到磁盘中,腾出内存空间。这样的过程叫做页面置换 硬件支持 为了支持页面置换,页表需要得到一些硬件支持,比如存在位,页面缺失错