{p1,..., pk : p1 < p2 <...< pk} is called a prime k -tuple of distance s if p1, p2,..., pk are consecutive prime numbers and pk - p1 = s . For example ...
分类:
其他好文 时间:
2016-09-16 22:51:09
阅读次数:
213
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest l ...
分类:
其他好文 时间:
2016-09-16 19:40:27
阅读次数:
98
传送门 Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence (a1, a2, ..., aN) be any ...
分类:
其他好文 时间:
2016-09-16 00:16:11
阅读次数:
138
原博文:传送门 最长递增子序列(Longest Increasing Subsequence) 下面我们简记为 LIS。假设存在一个序列d[1..9] = 2 1 5 3 6 4 8 9 7,可以看出来它的LIS长度为5。下面一步一步试着找出它。我们定义一个序列B,然后令 i = 1 to 9 逐个 ...
分类:
编程语言 时间:
2016-09-16 00:08:32
阅读次数:
282
问题描述: 给定一个字符串S,找出它的最大的回文子串,你可以假设字符串的最大长度是1000,而且存在唯一的最长回文子串 。 思路分析: 动态规划的思路:dp[i][j] 表示的是 从i 到 j 的字串,是否是回文串。 则根据回文的规则我们可以知道: 如果s[i] == s[j] 那么是否是回文决定于 ...
分类:
其他好文 时间:
2016-09-14 20:41:45
阅读次数:
131
题目链接: http://poj.org/problem?id=2533 Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric s ...
分类:
其他好文 时间:
2016-09-13 22:21:59
阅读次数:
177
104. Maximum Depth of Binary Tree Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from th ...
分类:
其他好文 时间:
2016-09-13 13:29:52
阅读次数:
150
以下是这段时间抽时间刷的前5题,都是自己想的解法,或许不是最优解,只是整理下,方便日后优化提升 1. Two Sum: 2. Add Two Numbers: 3. Longest Substring Without Repeating Characters: 4. Median of Two So ...
分类:
其他好文 时间:
2016-09-12 23:49:33
阅读次数:
224
Write a function to find the longest common prefix string amongst an array of strings. Solution1: 思路:没有想到什么巧妙方法。就用recursion暴力硬做。发现只要想法对,recursion怎么做都能 ...
分类:
其他好文 时间:
2016-09-12 07:21:25
阅读次数:
125
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest l ...
分类:
其他好文 时间:
2016-09-11 23:02:10
阅读次数:
142