上一页 1 ··· 3 4 5 6 7 8 9 10 11 下一页
摘要: https://www.cnblogs.com/wangkundentisy/p/8946858.html 结论: 对于数字n,计算它的第i(i从1开始,从右边开始计数)位数上包含的数字1的个数: 假设第i位上的数字为x的话,则 1.如果x > 1的话,则第i位数上包含的1的数目为:(高位数字 + 阅读全文
posted @ 2020-02-17 16:15 靖愁 阅读(203) 评论(0) 推荐(0) 编辑
摘要: 视频:AcWing 55. 连续子数组的最大和 思路 class Solution { public: int maxSubArray(vector<int>& nums) { int res=INT_MIN;//INT_MIN:负无穷 int sum = 0; for(int i=0 ; i<nu 阅读全文
posted @ 2020-02-17 15:14 靖愁 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 思路:AcWing 54. 数据流中的中位数 将数组分成两半,一个大顶堆和一个小顶堆,大顶堆维护小于中位数的所有元素,小顶堆维护大于中位数的所有元素,两个堆的元素数量差不能超过2,超过2就互相匀一匀。 代码: class Solution { priority_queue<int> maxHeap; 阅读全文
posted @ 2020-02-17 13:46 靖愁 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 知识点: c++优先队列(priority_queue)用法详解 push 插入元素到队尾 (并排序) priority_queue的常见用法 priority_queue队列优先级的设置 基本数据类型优先级的设置 对于基础类型,一般是数字大的优先级高,对于字符,就是字典序越大,优先级越高。 pri 阅读全文
posted @ 2020-02-16 18:30 靖愁 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 视频:https://www.acwing.com/video/176/ class Solution { public: int moreThanHalfNum_Solution(vector<int>& nums) { int cnt = 1,val = nums[0]; for(int i=1 阅读全文
posted @ 2020-02-16 16:45 靖愁 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 爆搜问题 看这个,别看下面的视频 https://www.bilibili.com/video/av9830088 对应代码 1 class Solution { 2 public: 3 vector<string> result; 4 5 vector<string> Permutation(st 阅读全文
posted @ 2020-02-16 13:02 靖愁 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 代码 序列化二叉树 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), lef 阅读全文
posted @ 2020-02-16 12:01 靖愁 阅读(208) 评论(0) 推荐(0) 编辑
摘要: https://www.bilibili.com/video/av91129831 栈做https://www.nowcoder.com/profile/6084631/codeBookDetail?submissionId=15463248 队列做https://www.nowcoder.com/ 阅读全文
posted @ 2020-02-16 10:12 靖愁 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 视频 题目描述搬用工,然后自己可劲儿备注为了自己看懂~1.遍历链表依次在本来结点后面添加他的复制结点np;2.如果说这个结点有random,那么就:自己画图好好寻思吧,23333.最后把复制结点提炼出来成新链表,这里需要先定义一个虚假的头结点和尾结点。 代码:https://www.acwing.c 阅读全文
posted @ 2020-02-15 21:58 靖愁 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 视频:https://www.acwing.com/video/171/ 很好的展示了代码怎么写。 结合递归细品 C++递归 class Solution { public: //int sum ; vector<vector<int>> res; //答案数据,定义成类里面的全局变量 vector 阅读全文
posted @ 2020-02-15 19:28 靖愁 阅读(132) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 下一页