题目
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent
a number.
An example is the root-to-leaf path 1->2->3 which represents the number 123.
Find ...
分类:
其他好文 时间:
2014-07-08 21:43:08
阅读次数:
219
深度优先搜索(DFS)是搜索算法的一种。最早接触DFS应该是在二叉树的遍历里面,二叉树的先序、中序和后序遍历实际上都属于深度优先遍历,实质就是深度优先搜索,后来在图的深度优先遍历中则看到了更纯正的深度优先搜索算法。
通常,我们将回溯法和DFS等同看待,可以用一个等式表示它们的关系:回溯法=DFS+剪枝。所以回溯法是DFS的延伸,其目的在于通过剪枝使得在深度优先搜索过程中如果满足了回...
分类:
其他好文 时间:
2014-07-08 20:34:20
阅读次数:
271
二维码(Two-dimensional code)是用某种特定的几何图形按一定规律在平面(二维方向)分布的黑白相间的图形记录数据符号信息的方式。现实生活中,二维码普遍存在我们的周围,例如:产品防伪/溯源、广告推送、网站链接、数据下载、商品交易、定位/导航、电子凭证、车辆管理、信息传递、名片交流、wifi共享等。
在代码编制上巧妙地利用构成计算机内部逻辑基础的“0”、“1”比特流的概念,使...
分类:
其他好文 时间:
2014-07-08 20:07:51
阅读次数:
260
Problem Description:
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 in the array which gives the sum of zero.
Note:
El...
分类:
其他好文 时间:
2014-07-08 18:31:01
阅读次数:
159
Designing a Class Interface
设计类接口
The Objective-C syntax for creating a class is very simple. It typically comes in two parts.
创建类的语法是很简单的,通常包括两部分。
The class interface is u...
分类:
其他好文 时间:
2014-07-08 16:24:27
阅读次数:
168
二叉树的三种遍历有递归版本,和迭代版本。本文介绍一种新的思路。
参考了 http://coolshell.cn/articles/9886.html
在许多应用中,我们还需要对遍历本身进行抽象。假如有一个求和的函数sum,我们希望它能应用于链表,数组,二叉树等等不同的数据结构。这时,我们可以抽象出迭代器(Iterator)的概念,通过迭代器把算法和数据结构解耦了,使得通用算法能应用于不同类...
分类:
其他好文 时间:
2014-07-08 15:41:35
阅读次数:
176
Given n non-negative integers a1, a2,
..., an, where each represents a point at coordinate (i, ai). n vertical
lines are drawn such that the two endpoints of line i is at (i, ai) and (i,
0). Fin...
分类:
其他好文 时间:
2014-07-08 14:21:56
阅读次数:
190
The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are summed and the process ...
分类:
其他好文 时间:
2014-07-08 14:12:32
阅读次数:
226
题目
Given a linked list, swap every two adjacent nodes and return its head.
For example,
Given 1->2->3->4, you should return the list as 2->1->4->3.
Your algorithm should use only constant spac...
分类:
其他好文 时间:
2014-07-08 13:46:26
阅读次数:
205
SharePoint Tips about Permissions: What you need to knowI have been writing tips about SharePoint from last two years now. After a great popularity an...
分类:
其他好文 时间:
2014-07-08 00:36:33
阅读次数:
262