题目: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...
分类:
其他好文 时间:
2014-05-23 12:40:21
阅读次数:
352
题目:Given a binary tree, determine if it is a valid
binary search tree (BST).Assume a BST is defined as follows:The left subtree of
a node contains onl...
分类:
其他好文 时间:
2014-05-23 12:20:50
阅读次数:
407
题目:Two elements of a binary search tree (BST) are
swapped by mistake.Recover the tree without changing its structure.Note:A
solution using O(n) space ...
分类:
其他好文 时间:
2014-05-23 11:31:51
阅读次数:
299
题目描述:
给定一个n*m的迷宫,如
S..
..#
E.E
其中,S代表开始位置,#代表不可行走的墙,E代表出口。
主人公从开始位置出发,每次等概率的随机选择下一个可以行走的位置,直到到达某一个出口为止。
现在他想知道,在这一概率事件中,它从开始位置走到某一个出口的期望步数是多少。
输入:
输入包含多组测试用例,每组测试用例由两个整数n,m(1
接下去...
分类:
其他好文 时间:
2014-05-18 10:34:57
阅读次数:
260
之前看过Python学习的经验,说以工程为导向学习。
自己分析了一下,一般接触Python的都有一定的其他语言基础,对于程序设计的基本逻辑,语法都有一个大概的了解。而Python这种脚本语言,没有过于独特的语法,在一定的其他语言的基础上,更是可以直接上手的。
之前看Python简明教程,半天没有进度。正好遇上Python爬虫项目,直接上手,方便快捷。
网站:http://acm.njupt.edu.cn/welcome.do?method=index,正值系统更新,于是写一个备份代码的爬虫。...
分类:
编程语言 时间:
2014-05-18 08:25:35
阅读次数:
461
1、
??
ZigZag Conversion
The string "PAYPALISHIRING" is
written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibili...
分类:
其他好文 时间:
2014-05-18 07:56:49
阅读次数:
407
剑指offer上的第20题,九度OJ上测试通过。
题目描述:
输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下矩阵:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
则依次打印出数字1,2,3,4,8,12,16,15,14,13,9,5,6,7,11,10.
输入:
输入可能包含多个测试样例,对于每个测试案例,
输入的第一行包括两个整数m和n(1<=m,n<=1000):表示矩阵的维数为m行n列。
接下来的m行,每行包括n个整数,表示矩阵的元素...
分类:
其他好文 时间:
2014-05-18 06:09:11
阅读次数:
317
1、
??
Path Sum
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...
分类:
其他好文 时间:
2014-05-18 03:25:06
阅读次数:
301
剑指offer上的第14题,九度OJ为了确保输出的结果的唯一性,在输出上做了修改,因此采用的方法自然与书本上不同,这里没有限制,思来想去还是用最简单的方法来做了,非常简单的方法,直接上代码。
题目描述:
输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分,所有的偶数位于位于数组的后半部分,并保证奇数和奇数,偶数和偶数之间的相对位置不变。
输入:
每个输入文件包含一组测试案例。
对于每个测试案例,第一行输入一个n,代表该数组中数字的个数。
接下来的一行输入n个整数。代表...
分类:
其他好文 时间:
2014-05-15 08:14:26
阅读次数:
285
C - 神奇的%系列一
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/32768 KB
(Java/Others)
Submit Status
Problem Description
在计算机的世界里,%不是百分比,而是除法取余哟!
比如:
4 % 2 = 0...
分类:
其他好文 时间:
2014-05-15 00:10:37
阅读次数:
308