www

导航

2017年9月22日 #

Minimum Size Subarray Sum

摘要: public int minSubArrayLen(int[] nums, int s) { if(nums==null||nums.length==0) return 0; int i=0,j=0; int sum=0, int ret=Integer.MAX_VALUE; while(j=s){ ret=Math.min(ret,j-i... 阅读全文

posted @ 2017-09-22 20:38 www_practice 阅读(118) 评论(0) 推荐(0) 编辑

和为S的两个数

摘要: pair FindNumbersWithSum(vector input, int sum) { pair result; int len=input.size(); if(len<2) return result; sort(input.begin(), input.end()); ... 阅读全文

posted @ 2017-09-22 19:28 www_practice 阅读(137) 评论(0) 推荐(0) 编辑

二叉树的后序遍历序列

摘要: bool helper(vector &input, int start, int end) { if(start>=end) return true; int mark=input[end]; int pos=-1; for(int i=start; imark) {... 阅读全文

posted @ 2017-09-22 19:21 www_practice 阅读(241) 评论(0) 推荐(0) 编辑

从上往下遍历二叉树

摘要: vector TravelFromTopToBottom(TreeNode* root) { vector result; if(root==nullptr) return result; queue MyQueue; MyQueue.push(root); while(!M... 阅读全文

posted @ 2017-09-22 17:13 www_practice 阅读(264) 评论(0) 推荐(0) 编辑

树的子结构

摘要: bool helper(TreeNode *root1, TreeNode *root2) { if(root2==nullptr) return true; if(root1==nullptr) return false; if(root1->val==root2->val) ... 阅读全文

posted @ 2017-09-22 16:38 www_practice 阅读(153) 评论(0) 推荐(0) 编辑

合并两个排序链表

摘要: ListNode* Merge(ListNode* p1, ListNode* p2) { if(p1==nullptr) return p2; if(p2==nullptr) return p1; int val1=p1->val; int val2=p2->val; ... 阅读全文

posted @ 2017-09-22 15:50 www_practice 阅读(138) 评论(0) 推荐(0) 编辑

TCP UDP详解 转载(http://www.cnblogs.com/visily/archive/2013/03/15/2961190.html)

摘要: 1、传输层存在的必要性 由于网络层的分组传输是不可靠的,无法了解数据到达终点的时间,无法了解数据未达终点的状态。因此有必要增强网络层提供服务的服务质量。 2、引入传输层的原因 面向连接的传输服务与面向连接的网络服务类似,都分为建立连接、数据传输、释放连接三个阶段;编址、寻址、流控制也是类似的。无连接 阅读全文

posted @ 2017-09-22 12:42 www_practice 阅读(177) 评论(0) 推荐(0) 编辑

两个栈实现队列

摘要: class MyQueue { public: void push(int key) { stack1.push(key); } int pop() { if(stack2.empty()) { while(!stack1.empty()) { ... 阅读全文

posted @ 2017-09-22 11:12 www_practice 阅读(94) 评论(0) 推荐(0) 编辑

旋转数组中的最小数字

摘要: int minNumberInRotateArray(vector input) { int len=input.size(); if(len==0) return 0; int left=0, right=len-1; int result=INT_MAX; while(left... 阅读全文

posted @ 2017-09-22 10:56 www_practice 阅读(114) 评论(0) 推荐(0) 编辑