自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 socket、Tcp/IP通信

1.使用udp和tcp进程网络传输,为什么tcp能保证包是发送顺序,而 udp无法保证? 主机每次发送数据时,TCP就给每个数据包分配一个序列号并且在一个特定的时间内等待接收主机对分配的这个序列号进行确认,如果发送主机在一个特定时间内没有收到接收主机的确认,则发送主机会重传此数据包。接收主机利用序列号对接收的数据进行确认,以便检测对方发送的数据是否有丢失或者乱序等,接收主机一旦收到已经顺序

2015-07-27 22:44:13 980

原创 [leetcode]Word Ladder

#include<iostream>#include<string>#include<set>#include<unordered_set>#include<unordered_map>#include<map>#include<deque>using namespace std;class Solution{public: int wordladder(string s

2015-07-25 15:03:23 212

原创 [leetcode]Search for a Range

#include<iostream>#include<vector>using namespace std;class Solution1{public: vector<int> findindex(vector<int>a,int target) { vector<int>res; int first=0,last=a.size()-1;

2015-07-24 21:56:12 205

原创 [leetcode]Search Insert Position

#include<iostream>#include<vector>using namespace std;class Solution{public: int findindex(vector<int>a,int target) { if(a.empty()) return 0; int first=0,last=a

2015-07-24 17:24:23 180

原创 [leetcode]Search a 2D Matrix

#include<iostream>#include<vector>using namespace std;class Solution{public: bool find(vector<vector<int>>a,int target) { int l=0; int r=a.size()*a.back().size()-1;

2015-07-24 17:07:14 182

原创 [leetcode]First Missing Positive

#include<iostream>using namespace std;void findfirstpositive(int a[],int length){ for(int i=0;i<length;i++) { if(a[i]>0&&a[i]<=length&&i!=a[i]-1) { swap(a[i],a[a[i

2015-07-20 17:13:51 202

原创 [leetcode] Insertion Sort List

#include<iostream>using namespace std;struct ListNode{ int value; ListNode* next; ListNode(int value):value(value),next(NULL){};};ListNode* Insertsort(ListNode* head){ if(!head)

2015-07-20 15:47:37 220

原创 排序

#include<iostream>using namespace std;void Insertsort(int a[],int length){ /*int i,j,temp; for(i=0;i<length-1;i++) { j=i+1; if(a[j]<a[i]) { temp=a[j];

2015-07-18 11:48:01 194

原创 [leetcode] Convert Sorted List to Binary Search Tree

#include<iostream>#include<vector>using namespace std;struct TreeNode{ int val; TreeNode* left; TreeNode* right; TreeNode(int val):val(val),left(NULL),right(NULL){};};struct ListN

2015-07-17 16:32:49 228

原创 [leetcode]Convert Sorted Array to Binary Search Tree

#include<iostream>#include<vector>using namespace std;struct TreeNode{ int val; TreeNode* left; TreeNode* right; TreeNode(int val):val(val),left(NULL),right(NULL){};};class Soluti

2015-07-17 14:51:07 207

原创 Validate Binary Search Tree

#include<iostream>#include<vector>using namespace std;struct TreeNode{ int val; TreeNode* left; TreeNode* right; TreeNode(int val):val(val),left(NULL),right(NULL){};};class Soluti

2015-07-17 11:15:20 219

原创 [leetcode]Unique Binary Search Trees II

#include<iostream>#include<vector>using namespace std;struct TreeNode{ int val; TreeNode* left; TreeNode* right; TreeNode(int val):val(val),left(NULL),right(NULL){};};class Soluti

2015-07-16 22:40:57 239

原创 面试题目积累

19.C++多态的实现原理 对于虚函数调用来说,每一个对象内部都有一个虚表指针,该虚表指针被初始化为本类的虚表。所以在程序中,不管你的对象类型如何转换,但该对象内部的虚表指针是固定的,所以呢,才能实现动态的对象函数调用,这就是C++多态性实现的原理。

2015-07-16 22:36:18 599

原创 【leetcode】Construct Binary Tree from Preorder and Inorder Traversal

#include<iostream>#include<vector>#include<map>using namespace std;struct TreeNode{ int val; TreeNode* left; TreeNode* right; TreeNode(int val):val(val),left(NULL),right(NULL){};};

2015-07-16 17:28:07 189

原创 【leetcode】Populating Next Right Pointers in Each Node II

#include<iostream>#include<vector>#include<deque>#include<stack>using namespace std;struct TreeNode{ int val; TreeNode* left; TreeNode* right; TreeNode(int val):val(val),left(NULL

2015-07-14 15:21:10 147

原创 【leetcode】Flatten Binary Tree to Linked List

前序遍历二叉树,并进行扁平化处理#include<iostream>#include<vector>#include<deque>#include<stack>using namespace std;struct TreeNode{ int val; TreeNode* left; TreeNode* right; TreeNode(int val):va

2015-07-14 11:01:02 165

原创 【leetcode】Same Tree和Balanced Binary Tree

#include<iostream>#include<vector>#include<deque>using namespace std;struct TreeNode{ int val; TreeNode* left; TreeNode* right; TreeNode(int val):val(val),left(NULL),right(NULL){};

2015-07-13 23:32:08 147

原创 Recover Binary Search Tree

#include<iostream>#include<vector>using namespace std;struct TreeNode{ int val; TreeNode* left; TreeNode* right; TreeNode(int val):val(val),left(NULL),right(NULL){};};class Soluti

2015-07-13 21:23:16 163

原创 [leetcode] Binary Tree Zigzag Level Order Traversal

#include<iostream>#include<list>#include<queue>#include<vector>using namespace std;struct TreeNode{ int val; TreeNode* left; TreeNode* right; TreeNode(int value):val(value),left(NU

2015-07-13 16:11:31 150

原创 [leetcode]Binary Tree Level Order Traversal II

#include<iostream>#include<list>#include<queue>#include<vector>using namespace std;struct TreeNode{ int val; TreeNode* left; TreeNode* right; TreeNode(int value):val(value),left(NU

2015-07-13 16:07:51 182

原创 Morris遍历二叉树

#include<iostream>#include<list>using namespace std;struct TreeNode{ int value; TreeNode* left; TreeNode* right; TreeNode(int value):value(value),left(NULL),right(NULL){};};class So

2015-07-13 10:56:01 224

原创 【leetcode】Evaluate Reverse Polish Notation

#include<iostream>#include<stack>#include<string>#include<vector>using namespace std;class Solution{public: double fun(vector<string> a) { stack<string>result; for(int i=0

2015-07-11 15:55:16 167

原创 【leetcode】Largest Rectangle in Histogram

#include<iostream>#include<vector>using namespace std;class Solution{public: int fun(vector<int> a) { int i; int maxlength=0; for( i=0;i<a.size();i++) {

2015-07-11 14:01:31 200

原创 【leetcode】Longest Valid Parentheses

#include<iostream>#include<stack>#include<vector>#include<string>#include<algorithm>using namespace std;struct Node{ int key; char c; Node(int key,char c):key(key),c(c){};};class So

2015-07-11 10:56:46 151

原创 【leetcode】 Anagrams

代码1:#include<iostream>#include<string>#include<vector>#include<algorithm>#include<map>using namespace std;class Solution{public: string fun(vector<string> str) { string a="";

2015-07-08 15:58:54 212

原创 Wildcard Matching

迭代:#include<iostream>using namespace std;class Solution{public: bool isMatch(const char *s, const char *p) { int i=0,j=0; bool str=false; for(;s[i]!='\0

2015-07-07 20:31:52 235

原创 Longest Palindromic Substring

暴力解法:#include<iostream>#include<string>using namespace std;string expand(string a,int l,int r){ while(l>=0&&r<a.size()) { if(a[l]==a[r]) { l--; r++;

2015-07-07 14:58:05 228

原创 LRU Cache的C++实现

方法一:双链表+哈希表map#include<iostream>#include<map>using namespace std;struct Node{ int key; int value; Node* pre; Node* next; Node(int key=-1,int value=-1):key(key),value(value),pre(

2015-07-05 16:02:44 350

原创 【leetcode】Reorder List

描述 Given a singly linked list L : L0 -> L1->…-> Ln-1 -> Ln, reorder it to: L0 ->Ln -> L1 ->Ln-1 -> L2 -> Ln-2 ->…    You must do this in-place without altering the nodes’ values. For example, G

2015-07-03 10:15:33 201

原创 Single Number II

leetcode Single Number II 描述 Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could

2015-07-01 15:11:32 218

空空如也

空空如也

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

TA关注的人

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