自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(28)
  • 问答 (1)
  • 收藏
  • 关注

原创 重建二叉树 leetcode

http://www.cplusplus.com/reference/algorithm/find/

2014-11-17 20:20:15 625

原创 把树变成链表 Flatten Binary Tree to Linked List

思路是:拉直的顺序相当于先序遍历,所以先访问根,再访问左子树,再访问youzh

2014-11-13 16:26:58 353

原创 subset 集合子集问题

这个帖子讲的很好很详细 下面是我的解法,使用的是第二种思路

2014-11-08 19:48:20 497

原创 关于全排列 leetcode

Title Add Date Acceptance Difficulty Permutation Sequence 2012-03-27 22.3% Medium Permutations II 2012-03-16 25.0% Hard Permutat

2014-11-05 21:40:05 350

原创 Search for a Range 两种解法

自己的版本,二分查找,找到的时候liy

2014-10-31 15:46:13 510

原创 Longest Valid Parentheses

#include #include #include #include using namespace std; /** Longest Valid Parentheses Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed

2014-10-28 12:01:46 316

原创 anagrams两种解法 用map来优化查找

#include #include #include #include #include using namespace std; /** Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be in lower-case. Anagram(回

2014-10-26 18:00:22 699

原创 Add Binary leetcode

class Solution { public: /** 注意的问题:1,从低位相加,故a,b数组从最末开始,需要分两个下标i,j 2,相加需要int,但数组a,b的元素为 char,所以任何操作都需要-‘0’,特别是最后出来后b[j]+addc的时候,注意是((b[j]-'0') + addc)/2; 3,vector的push_back操作是末尾

2014-10-22 19:34:26 438

原创 String to Integer(ATOI) leetcode

对题目的理解: 1.前面如果有其他的字符,只能是空格,若有其他字符也是非法 2.前面只能有一个+  - 或者没有,如果出现 +-2,或者 ++ 2,也是非法 3.越界非法

2014-10-22 16:00:07 310

原创 Reorder List leetcode 易出错点已标记

#include using namespace std; /** Reorder List Total Accepted: 23179 Total Submissions: 113917 My Submissions Question Solution Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L

2014-10-20 10:15:40 429

原创 remove the nth node from the end of list leetcode

AC的代码,注意设置的连个

2014-10-18 12:56:07 334

转载 valid sodoku

class Solution{ public: bool isValidSudoku(vector > &board) { // Note: The Solution object is instantiated only once. vector> rows(9, vector(9,false)); vector> co

2014-10-14 17:05:05 426

原创 single number II

注意定义数组赋初值和右移存入的是最低位,c[]

2014-10-14 16:44:42 328

原创 3Sum leetcode解法 分析

坑死人不偿命的3Sum,知道思路,改了一晚上才改好,各种小错 #include #include #include using namespace std; /** Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets

2014-10-05 23:07:31 507

原创 remove duplicates from sorted array I II一些思路

在已排序的数组中去除重复元素,要求不使用多余的kongj

2014-09-28 17:08:04 414

原创 ZigZag Conversion刷题

ZigZag Conversion  Total Accepted: 11937 Total Submissions: 50113My Submissions The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may w

2014-08-31 22:47:38 494

原创 Add Two Numbers 看着简单,其实各种奇葩情况需要考虑。。。

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNo

2014-08-31 13:50:39 423

转载 Longest substring without repeating characters解法

做了一周的题,看见各种解法,发现这种解法最精妙

2014-08-28 12:18:48 518

原创 二叉树建立及遍历 实例

完整的给出二叉树递归建立和非递归先序,递归后序代码

2014-08-12 19:36:33 391

转载 new对象和直接声明对象的区别

在C++中,内存分成5个区,他们分别是堆、栈、自由存储区、全局/静态存储区和常量存储区

2014-08-12 17:07:16 554

原创 insertion sort list刷题 leetcode

先分析一般情况下的插入排序,给定数组A,从第2个元素开始,与执勤啊

2014-07-22 09:34:03 337

原创 Sort List leetcode刷题

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode *so

2014-07-19 15:01:42 397

转载 7.14老师需要的修改 关于多路径相关性

cwnd决定每次可以连续发多少个包,可用窗口决定是否可以发包

2014-07-15 09:54:23 670

转载 摘录TCP,ttl计算更新方法

RTT:对往返时间的当前最佳估计值 当一个数据段被发送出去后,TCP 启动定时器,如果在定时器过期之前确认数据段回来的话,则 TCP 测量一下这次确认所花的时间 M,然后根据如下公式更新 RTT。   RTT = aRTT + (1-a)M   其中 a 是平滑因子,典型的值是 7/8 这个公式的意思就是说,旧的 RTT 占有 7/8 的权重,新的往返时间占有

2014-07-15 09:30:58 1379

原创 Swap Nodes in Pairs刷题历程

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode *sw

2014-07-14 09:42:10 391

原创 模拟退火法与调度VM pair问题

模拟退火算法以一定的概率来接受一个比当前解要差的解,因此有可能会跳出这个局部的最优解,达到全局的最优解。以图1为例,模拟退火算法在搜索到局部最优解A后,会以一定的概率接受到E的移动。也许经过几次这样的不是局部最优的移动后会到达D点,于是就跳出了局部最大值A。

2014-07-13 17:37:19 750

原创 二分思想

二分的思想是找一个mid值,然后根据mid把需要查找的数组

2014-07-13 17:35:10 352

原创 leetcode刷题,我的解法1 twosum问题

struct node{     int num,pos; }; bool cmp(node a,node b){     return a.num } class Solution { public:     vector twoSum(vector &numbers, int target) {         vector copy; //定义node类型的矢量,赋值的时候

2014-07-10 16:48:57 483

空空如也

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

TA关注的人

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