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 and sum
= 22,
5
/ ...
分类:
其他好文 时间:
2015-01-14 16:55:08
阅读次数:
202
Given a binary tree, determine if it is height-balanced.
For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe...
分类:
其他好文 时间:
2015-01-14 15:33:12
阅读次数:
141
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 3
But the f...
分类:
其他好文 时间:
2015-01-14 11:08:56
阅读次数:
154
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.
/**
* Defin...
分类:
其他好文 时间:
2015-01-14 09:48:40
阅读次数:
139
首先要感谢上海大学的kuangbin大神,他正在VJ上开一个又一个的专题,为了让我这种弱渣入门。 从今天开始我就要根据bin神专题来进行学习和刷题了。 首先第一个专题就是搜索,先是基础搜索。 基础的搜索包括 DFS(深度优先搜索),BFS(广度优先搜索),回溯搜索,双向广度搜索,枚举搜...
分类:
其他好文 时间:
2015-01-12 23:54:54
阅读次数:
350
这是一道纯正的深度优先搜索题目。题目要求在有多少个不同的块,而不同块的定义则是,一个块中的任意一点和l另一个块中的任意一点不会相连,而相连的定义则是在横向、纵向和对角线上相连。#include#includechar map[101][101];int m,n;int search(int x,in...
分类:
其他好文 时间:
2015-01-12 20:44:03
阅读次数:
111
题目:
围棋中,一个棋子在棋盘上,与它直接紧邻的空点是这个棋子的“气”,棋子直接紧邻的点上,如果有同色妻子存在,则它们便相互组成一个不可分割的整体,它们的“气”也应一并计算。如果一个或一片棋子的“气”为0,那它们将被吃掉。
1. 一个棋子的情况,如下左图,白棋右侧还有一个空点,此时白棋气为1,不会被吃掉。当黑棋在此空点下棋后,白棋气为0,将被吃掉。
2. 一片棋子的情况,如下图,...
分类:
其他好文 时间:
2015-01-12 09:22:59
阅读次数:
286
需要解决的几个问题:1、硬盘文件检索2、多线程3、word打开超时或者出现异常情况第一个问题,用的是递归方法,深度优先。据查资料,有个api命令"FindFirstFile"、"FindNextFile",可以更高效地列出所有目录,速度很快,没有进行深入研究第二个问题,使用的是manage,可以很方...
分类:
其他好文 时间:
2015-01-11 17:24:17
阅读次数:
226
import random
#warning: x and y confusing
sx = 10
sy = 10
dfs = [[0 for col in range(sx)] for row in range(sy)]
maze = [[' ' for col in range(2*sx+1)] for row in range(2*sy+1)]
#1:up 2:down 3:left 4...
分类:
编程语言 时间:
2015-01-08 15:24:22
阅读次数:
158
编写完成重点数据结构和算法: 0.链表 1.栈 2.队列 3.二叉树数据结构和构建 4.前序中序后序遍历二叉树 5.构建哈夫曼树(最优二叉树) 6.图数据结构,图的深度优先遍历和广度优先遍历 7.拓扑排序 8.直接插入排序 9.希尔排序 10.希尔排序 11.冒泡排序 12.快速排序 13.直接选择...
分类:
其他好文 时间:
2015-01-07 01:50:00
阅读次数:
205