Problem Description:
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 only nodes with keys l...
分类:
其他好文 时间:
2014-05-15 11:22:21
阅读次数:
317
本文为senlie原创,转载请保留此地址:http://blog.csdn.net/zhengsenlie
Unique Binary Search Trees II
Total Accepted: 7349 Total
Submissions: 27648
Given n, generate all structurally unique ...
分类:
其他好文 时间:
2014-05-15 07:02:36
阅读次数:
252
OJ题目:click here~~
题目分析:有n条路径逃出洞穴,第i条路径有一个难度值ci。某人开始有战斗值f,每天随机选择某一条路径想要逃出。只要此时的 f 大于所选路径的ci,就能花费ti的天数逃出。这里。否则,等待明天再试吧,但是战斗值能增加ci。求逃出的期望天数。
设dp[ i ] 为战斗值为i时,逃出的期望天数。详细解释见代码。
AC_CODE
int const maxn =...
分类:
其他好文 时间:
2014-05-15 06:38:40
阅读次数:
406
题意:输出一个元素在一个已排序的数组中的位置,如果不存在输出它应该插入的位置
思路:二分查找,如果找到就输出位置,找不到就输出它应该插入的位置
复杂度:时间O(log n),空间O(1)
相关题目:
Search for a Range
Search a 2D Matrix...
分类:
其他好文 时间:
2014-05-15 05:57:32
阅读次数:
271
Pat1043代码
题目描述:
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:
The left subtree of a node contains only nodes with keys less than t...
分类:
其他好文 时间:
2014-05-15 05:09:59
阅读次数:
351
1.什么是re
正则表达式一门相对通用的语言,在python中也有对正则表达式的支持,那就是的内置re模块。正则表达式就是一系列的规则去匹配字符串然后进行相应的操作,这些规则网上一搜一大片,而re则是运用正则表达式来提供一系列的功能强大的接口让我们来调用。通常我们在对日志文件进行操作的时候会对正则表达式运用的比较多来得到我们希望得到的数据。
2.python中的转义符...
分类:
编程语言 时间:
2014-05-15 03:58:49
阅读次数:
465
题目
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:
Integers in each row are sorted from left to right.The first integer...
分类:
其他好文 时间:
2014-05-15 03:41:11
阅读次数:
257
Unique Binary Search Trees, Given n, how many structurally unique BST's (binary search trees) that store values 1...n?...
分类:
其他好文 时间:
2014-05-15 02:32:11
阅读次数:
245
date--help用法:date[选项]...[+格式]或:date[-u|--utc|--universal][MMDDhhmm[[CC]YY][.ss]]以给定的格式显示当前时间,或是设置系统日期。-d,--date=字符串显示指定字符串所描述的时间,而非当前时间-f,--file=日期文件类似--date,从日期文件中按行读入时间描述-r,--refer..
分类:
系统相关 时间:
2014-05-14 16:11:37
阅读次数:
863
写论文的Idea哪里来?
1.寻求数学上的变化。
2.测试现有的他人方法的不足之处。
3.用多种方法详尽解决一个问题。
4.用一个方法解决多种问题。
5.善用跨学科成果。
最重要的2种能力:
1.实验能力。
2.检索能力。Research俗称Re-Search
写论文的要...
分类:
其他好文 时间:
2014-05-14 15:16:14
阅读次数:
266