1,关于递归还是要有时间就练习,又有些生疏了/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeN...
分类:
其他好文 时间:
2014-10-28 07:02:47
阅读次数:
141
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],
...
分类:
其他好文 时间:
2014-10-27 15:36:28
阅读次数:
190
聚合转换可以像T-SQL中的函数GROUP BY, Average, Minimum, Maximum, 和 Count一样对数据进行聚合运算。在图中可以看到数据以SampleID分组,对TotalSugar做Average、Maximum、Minimum、Count操作。这样产生了4列新的数据,供...
分类:
其他好文 时间:
2014-10-27 12:17:33
阅读次数:
169
Given a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ofs...
分类:
编程语言 时间:
2014-10-27 10:46:48
阅读次数:
230
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).
For example,
S = "ADOBECODEBANC"
T = "ABC"
Minimum window is "BAN...
1. 概述
RMQ(Range Minimum/Maximum Query),即区间最值查询,是指这样一个问题:对于长度为n的数列A,回答若干询问RMQ(A,i,j)(i,j当然,该问题也可以用线段树(也叫区间树)解决,算法复杂度为:O(N)~O(logN),这里我们暂不介绍。
2.RMQ算法
对于该问题,最容易想到的解决方案是遍历,复杂度是O(n)。但当数据量非常大...
分类:
其他好文 时间:
2014-10-25 21:36:10
阅读次数:
218
属于中规中矩的dp。和unique paths类似。一次ac。但是可以通过滚动数组来节省存储空间。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 class Solution { 7 public: 8 int...
分类:
其他好文 时间:
2014-10-25 21:19:04
阅读次数:
244
这道题是Search in Rotated Sorted Array的扩展,思路在Find Minimum in Rotated Sorted Array中已经介绍过了,和Find Minimum in Rotated Sorted Array唯一的区别是这道题目中元素会有重复的情况出现。不过正是因为这个条件的出现,影响到了算法的时间复杂度。原来我们是依靠中间和边缘元素的大小关系,来判断哪一半是不...
分类:
其他好文 时间:
2014-10-25 08:10:07
阅读次数:
206
这道题是Search in Rotated Sorted Array的扩展,区别就是现在不是找一个目标值了,而是在bst中找最小的元素。主要思路还是跟Search in Rotated Sorted Array差不多,还是通过左边界和中间的大小关系来得到左边或者右边有序的信息,如果左半边有序,那么左半边最小就是左边第一个元素,可以和当前最小相比取小的,然后走向右半边。否则,那么就是右半半边第一个元...
分类:
其他好文 时间:
2014-10-25 08:10:05
阅读次数:
200
Find Minimum in Rotated Sorted Array II Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-...
分类:
其他好文 时间:
2014-10-24 20:42:30
阅读次数:
299