自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(27)
  • 收藏
  • 关注

原创 位运算小结

n >>=1  :  n = n/2 n&1==1 : n%2 == 1 n = n&(n-1) 可以将n二进制中最右边1后面的数都变为0 如n =6,则 n = 110 & 101 = 100 求n的二进制位(反向  ) while(n){ cout<< n&1 ; n >> =1;}//n=6 (11...

2018-08-31 16:05:03 120

原创 输入vector生成三通道的Mat

string filename = "/data1/home/duyaru/SDK/xuanwu_sdk_0226/jpeg.value"; std::ifstream inf(filename); if (!inf.is_open()){ std::cout << "Error opening file"; } vector<int> res...

2018-08-30 15:37:11 1081

原创 深度学习 反向传播的过程

参见链接https://www.cnblogs.com/charlotte77/p/5629865.htmlkey:1.链式求导2.更新当前层的w 和 b 是对求导;而反向传播的delta 是对该层的输入求导。  

2018-08-24 22:30:53 499

原创 leetcode 反转链表

key:1. 定义三个指针,cur;newhead;cur的前一个结点 pre2.判断最后一个结点,直接赋值给newhead*** 如果是双向链表,就是多了一步往前的指针处理**** 如果是将二叉搜索树转换成有序的双向链表,也是一样的:中序遍历 + 根节点处的指针转换;同时要注意对于参数pre,要用*&解释:指针是一个存放地址的变量,而指针引用指的是这个变量的引用,...

2018-08-24 22:21:59 228

原创 leetcode 重建二叉树

key:1. 递归的返回条件:ps > pe;2. 左右子树的索引更新:其中index是根据前序遍历在中序遍历中找到的值preorder: (ps+1, ps+index-is);    (ps+index-is+1, pe)inorder: (is, index-1); (index+1, ie) class Solution {public: Tree...

2018-08-24 11:43:53 475

原创 字符串反转或转数字相关操作

https://www.jianshu.com/p/bc96329df0f7key:指针的使用 char * pstr;

2018-08-23 14:24:17 154

原创 leetcode binary-tree-maximum-path-sum

key:1.递归,每次返回当前节点作为父节点到任意子节点之间的最大距离。2.最大距离的评判标准:max(res,sum),其中 sum表示当前节点作为父节点时,任意子节点之间的距离和。  int res; int maxPathSum(TreeNode *root) { if(!root) return 0; res = INT_MIN;...

2018-08-23 08:55:12 91

原创 c++ 指针和引用的区别

参考链接:https://www.cnblogs.com/dingxiaoqiang/p/8012578.html指针和引用的相同点和不同点:★相同点:●都是地址的概念;指针指向一块内存,它的内容是所指内存的地址;而引用则是某块内存的别名。★不同点:●指针是一个实体,而引用仅是个别名;●引用只能在定义时被初始化一次,之后不可变;指针可变;引用“从一而终”,指针可以“见异...

2018-08-21 16:00:06 92

原创 c++ const

参考链接:https://www.geeksforgeeks.org/function-overloading-and-const-functions/作为函数,可以overload,const 函数 和 非const 函数作为参数,只有为引用或指针时,可以overload如 void fun(const int& i){};void fun(int& i){};...

2018-08-21 15:10:56 98

原创 c++ 为什么需要.h文件

参考地址:https://mp.weixin.qq.com/s?__biz=MzA5MjQ2MDg1Mg==&mid=2247483716&idx=1&sn=b14ace510810e593c44c6439f610e770&chksm=906d831fa71a0a096d3079b6fac11a9659e9fd12db0fc0307ae30690542a2e30...

2018-08-21 12:03:38 3914

原创 leetcode record list

题目:Given a singly linked list L: L 0→L 1→…→L n-1→L n,reorder it to: L 0→L n →L 1→L n-1→L 2→L n-2→…You must do this in-place without altering the nodes' values.For example,Given{1,2,3,4}, reord...

2018-08-20 10:42:50 197

原创 static的作用

https://blog.csdn.net/m0_38086436/article/details/80310946c++(1)隐藏 如果加了static,那么不会被其他源文件访问(java也有该性质)(2)保持变量内容的持久性(3)默认初始化为0java作用:为某特定数据类型或对象分配单一的存储空间,而与创建对象个数无关。与c++的区别:(1)java可以直接调用...

2018-08-19 14:48:30 854

原创 leetcode 二叉树 两个结点的最短距离

参考链接 https://www.cnblogs.com/wxdjss/p/5698071.html

2018-08-15 08:55:03 4756 1

原创 手写 queue 和dequeue

参考链接  https://blog.csdn.net/foreyes_1001/article/details/52215243

2018-08-14 23:02:35 1191

原创 leetcode z形遍历二叉树

key:  use two stack s1,s2 /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NU...

2018-08-14 22:49:59 783

原创 百度面试

1.linux题  一百亿个ip地址,其中有重复的,找出重复最多的前十个ip地址。cat ****.log | sort | uniq -c| sort -nr其中n表示按数值排序  r表示相反顺序排列

2018-08-14 18:07:42 428

转载 几种排序算法的比较

https://www.cnblogs.com/lizr-ithouse/p/5839384.html

2018-08-12 16:14:01 94

原创 leetcode 3sum

key1.sort array2.anchor one num, traverse otherstip:check the duplicated numscomapre with 2sumvector<vector<int> > threeSum(vector<int> &num) { sort(num.begin(...

2018-08-11 13:00:57 95

原创 two sum

key  hashmap  <key,value> = <num,index>vector<int> twoSum(vector<int> &numbers, int target) { unordered_map<int,int> map; vector<int> res;...

2018-08-11 13:00:31 89

原创 leetcode:max subArray

key:用贪心法。由于一定要包含一个值, 从当前位置考虑,要得到最大值,要么加上前面的,要么不加前面的。dp[i] = num[i] + dp[i-1] > 0? dp[i-1] : 0; int maxSubArray(int A[], int n) { vector<int> dp(n); dp[0] = A[0]; ...

2018-08-04 21:56:59 274

原创 leetcode:populating next right poniter in each node

key: two pointers,one for the first node in each levelone for each node in one specific level                   root    p->  node1 node2p->node3 node4 node5 node6         |         |...

2018-08-04 21:20:40 80

原创 leetcode:container with most water

key:  1.a group with two point from the both side.  2 calcu current area&& update maxarea && update the point with short height  3. do 2 until two point meet int maxArea(vecto...

2018-08-04 20:38:54 226

原创 leetcode: sort interval

key1: check vector  is emptykey2: sort vectorkey3: vector has functon of  vector.back() // get the last element; static bool cmp(Interval a, Interval b){ if(a.start == b.start) ...

2018-08-04 11:50:48 157

原创 leetcode : merge two sorted array

key: tranverse from the last index;  three point: m-1, n-1; m+n-1;void merge(int A[], int m, int B[], int n) { int i = m-1; int j = n-1; int start = m+n-1; while(i...

2018-08-04 11:17:24 212

原创 leetcode: merge two sorted linklist

key: dummy node; how to copy link node(p-> next = l)ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) { ListNode dummy(INT_MIN); ListNode *p = &dummy; while(l1 &amp...

2018-08-04 10:36:04 77

原创 leetcode : same tree or symmetric tree

key: use queue usage:  queue<node*> myq; myq.push(); myq.front(); myq.pop()  bool isSameTree(TreeNode *p, TreeNode *q) { queue<TreeNode*> myq; myq.push(p); m...

2018-08-04 10:15:40 128

原创 leetcode.Best Time to Buy and Sell Stock with Cooldown

这里都用了状态机,需要注意的是状态机表示当前状态下的最大收益a typical DP problemkey1 :   deduce the transition function .(buy,sell,rest) represents before day i what is the max profit  when the  sequence end with (buy, sell ...

2018-08-04 09:43:38 185

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除