/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode *g...
分类:
编程语言 时间:
2015-02-02 21:38:39
阅读次数:
203
数学定义[编辑]若k个随机变量、……、是相互独立,符合标准正态分布的随机变量(数学期望为0、方差为1),则随机变量Z的平方和被称为服从自由度为k的卡方分布,记作Definition[edit]IfZ1, ...,Zkareindependent,standard normalrandom varia...
分类:
其他好文 时间:
2015-02-01 17:32:23
阅读次数:
209
最近遇到很多问题都跟Prime有关,于是总结一下:Prime definition:Aprime number(or aprime) is anatural numbergreater than 1 that has no positivedivisorsother than 1 and itsel...
分类:
其他好文 时间:
2015-02-01 07:07:26
阅读次数:
217
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first
two lists.
#include
#include
using namespace std;
//Definition fo...
分类:
其他好文 时间:
2015-01-31 16:22:38
阅读次数:
152
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
解题思路:采用中序排列的方法递归地决定每个结点的数值;
#include
#include
#include
using namespace std;
//Definition...
分类:
其他好文 时间:
2015-01-30 16:00:24
阅读次数:
131
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?/** * Definition for singly-linked list. *...
分类:
其他好文 时间:
2015-01-29 12:07:35
阅读次数:
117
Given a binary tree, find the maximum path sum.
The path may start and end at any node in the tree.
求树的一点到另一点的最大路径,利用递归的方法,ans 在 左子树,右子树,root+左+右的最大中产生。
/**
* Definition for binary tree
* struct ...
分类:
其他好文 时间:
2015-01-27 22:01:36
阅读次数:
112
检测一个树是否平衡,不需要求出高度,而是从底到顶检测是否平衡,这样才算法时间复杂度为O(n)。但是需要额外的O(logn)的空间
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(...
分类:
其他好文 时间:
2015-01-27 21:55:39
阅读次数:
164
原题链接:https://oj.leetcode.com/problems/merge-two-sorted-lists/
这道题用指针的指针实现,做法会非常简单干净。直接上代码
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
*...
分类:
其他好文 时间:
2015-01-27 14:56:08
阅读次数:
109
Notes from C++PrimerIn general, head file includes: class definition, declaration of extern variable and declaration of function.1. Head file is used ...
分类:
其他好文 时间:
2015-01-27 13:01:17
阅读次数:
117