- 博客(28)
- 问答 (1)
- 收藏
- 关注
原创 把树变成链表 Flatten Binary Tree to Linked List
思路是:拉直的顺序相当于先序遍历,所以先访问根,再访问左子树,再访问youzh
2014-11-13 16:26:58
378
原创 关于全排列 leetcode
TitleAdd DateAcceptanceDifficultyPermutation Sequence2012-03-2722.3%MediumPermutations II2012-03-1625.0%HardPermutat
2014-11-05 21:40:05
388
原创 Longest Valid Parentheses
#include #include #include #include using namespace std;/**Longest Valid ParenthesesGiven a string containing just the characters '(' and ')', find the length of the longest valid (well-formed
2014-10-28 12:01:46
346
原创 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
730
原创 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
472
原创 String to Integer(ATOI) leetcode
对题目的理解:1.前面如果有其他的字符,只能是空格,若有其他字符也是非法2.前面只能有一个+ - 或者没有,如果出现 +-2,或者 ++ 2,也是非法3.越界非法
2014-10-22 16:00:07
343
原创 Reorder List leetcode 易出错点已标记
#include using namespace std;/**Reorder List Total Accepted: 23179 Total Submissions: 113917 My Submissions Question SolutionGiven a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L
2014-10-20 10:15:40
462
转载 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
461
原创 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
535
原创 remove duplicates from sorted array I II一些思路
在已排序的数组中去除重复元素,要求不使用多余的kongj
2014-09-28 17:08:04
438
原创 ZigZag Conversion刷题
ZigZag Conversion Total Accepted: 11937 Total Submissions: 50113My SubmissionsThe 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
528
原创 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
453
原创 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
420
转载 摘录TCP,ttl计算更新方法
RTT:对往返时间的当前最佳估计值当一个数据段被发送出去后,TCP 启动定时器,如果在定时器过期之前确认数据段回来的话,则 TCP 测量一下这次确认所花的时间 M,然后根据如下公式更新 RTT。 RTT = aRTT + (1-a)M 其中 a 是平滑因子,典型的值是 7/8这个公式的意思就是说,旧的 RTT 占有 7/8 的权重,新的往返时间占有
2014-07-15 09:30:58
1498
原创 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
404
原创 模拟退火法与调度VM pair问题
模拟退火算法以一定的概率来接受一个比当前解要差的解,因此有可能会跳出这个局部的最优解,达到全局的最优解。以图1为例,模拟退火算法在搜索到局部最优解A后,会以一定的概率接受到E的移动。也许经过几次这样的不是局部最优的移动后会到达D点,于是就跳出了局部最大值A。
2014-07-13 17:37:19
791
原创 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
512
空空如也
求问ubuntu 13.10下ns3.8安装遇到python2.7-config意外停止
2014-07-04
TA创建的收藏夹 TA关注的收藏夹
TA关注的人