上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 34 下一页
摘要: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the following is not: 1 / \ 2 2 \ \ 3 3Note:Bonus points if you could solve it both recursively and iterati... 阅读全文
posted @ 2013-12-05 22:25 七年之后 阅读(169) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.思考:考虑[1,2]这种情况,返回树最低高度为2。所以分两种情况,有一棵子树不在时,返回另一棵子树树高+1,否则返回矮子树高+1./** * Definition for binary tree * struct TreeNode { * int val; * Tre... 阅读全文
posted @ 2013-12-05 12:35 七年之后 阅读(159) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree andsum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ / \ 7 2 5 1return[ [5,4,11,2]... 阅读全文
posted @ 2013-12-05 12:10 七年之后 阅读(175) 评论(0) 推荐(0) 编辑
摘要: Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.思考:DFS./** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right... 阅读全文
posted @ 2013-12-05 10:50 七年之后 阅读(117) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree andsum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ ... 阅读全文
posted @ 2013-12-04 22:02 七年之后 阅读(184) 评论(0) 推荐(0) 编辑
摘要: Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [6,5,7], [4,1,8,3]]The minimum path sum from top to bottom is11(i.e.,2+3+5+1= 11).Note:Bonus point if you are a... 阅读全文
posted @ 2013-12-04 21:28 七年之后 阅读(214) 评论(0) 推荐(0) 编辑
摘要: Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the original relative order of the nodes in each of the two partitions.For example,Given1->4->3->2->5->2andx= 3,return1->2->2->4->3- 阅读全文
posted @ 2013-12-04 20:37 七年之后 阅读(209) 评论(0) 推荐(0) 编辑
摘要: “选择了错误的算法,便注定了失败的命运”。最近对这句话感触颇深,经常因为一开始思路错误,修改半天,到头来却都是无用功,所以学好算法势在必行。算法的泛化过程如何设计一个算法,使他适用于任何(大多数)数据结构呢?先看一个算法泛华的实例。假设我们要写一个find()函数,在array中寻找特定值。面对整数array,我们很快能写出:int *find(int *array,int size,int target){ for(int i=0;iT *find(T *begin,T *end,T& value){ while(begin!=end&&*begin!=value) 阅读全文
posted @ 2013-12-04 17:18 七年之后 阅读(532) 评论(0) 推荐(0) 编辑
摘要: The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is read off as"two 1s"or21.21is read off as"one 2, thenone 1"or1211.Given an integern, generate thenthsequence.Note: The sequence of inte 阅读全文
posted @ 2013-12-04 00:37 七年之后 阅读(244) 评论(0) 推荐(0) 编辑
摘要: 1.为什么选择NginxNginx是当前最流行的Web服务器之一,与Apache相比,Nginx在高并发情况下具有巨大的性能优势。Nginx具有高扩展性,高可靠性,低内存消耗等特点,并且Nginx拥有无数官方功能模块,第三方功能模块,这些功能模块可以叠加以实现更加强大/复杂的功能。选择Nginx的核心理由是它能在支持高并发请求的同时保持高效的服务。2.Nginx的安装与运行Nginx官方下载地址:http://nginx.org/en/download.html解压:$ tar -zxvf nginx-1.4.4.tar.gz进入nginx目录,执行如下命令:$ ./configure$ ma 阅读全文
posted @ 2013-12-02 17:37 七年之后 阅读(304) 评论(0) 推荐(0) 编辑
上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 34 下一页