问题描述Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longes...
分类:
其他好文 时间:
2015-07-27 13:02:11
阅读次数:
98
【032-Longest Valid Parentheses(最长有效括号)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses su...
分类:
编程语言 时间:
2015-07-26 07:31:04
阅读次数:
198
https://leetcode.com/problems/longest-palindromic-substring/题目:Given a stringS, find the longest palindromic substring inS. You may assume that the ma...
分类:
其他好文 时间:
2015-07-25 22:46:20
阅读次数:
200
10285 Longest Run on a Snowboard
Michael likes snowboarding. That’s not very surprising, since snowboarding is really great. The bad
thing is that in order to gain speed, the area must slide downward...
分类:
其他好文 时间:
2015-07-25 13:49:45
阅读次数:
269
题意:
给出一个有权树,求树上两点路径的最大异或和;
n
题解:
考虑异或的性质,如果任选一点为根,处理出所有点的异或深度;
那么将两点的深度异或起来,LCA到根的路径就异或了两次相当于没有;
所以异或距离就是两点异或深度的异或和,问题就转化成了从n个数中选两个数使异或和最大;
这个经典问题就可以把数字按位存进01trie树,从高位到低位贪心求解;
复杂度O(31n);
...
分类:
其他好文 时间:
2015-07-25 09:34:21
阅读次数:
109
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4, 200, 1, 3, 2],The longest ...
分类:
其他好文 时间:
2015-07-24 22:14:56
阅读次数:
115
题意: Given is an ordered deck of n cards numbered 1to n with card 1 at the top and card n at thebottom.The following operation is performed aslong as t...
分类:
其他好文 时间:
2015-07-24 22:06:58
阅读次数:
101
Write a function to find the longest common prefix string amongst an array of strings.class Solution {public: string longestCommonPrefix(vector& st...
分类:
其他好文 时间:
2015-07-24 06:55:48
阅读次数:
143
LeetCode 之 Valid Palindrome,本文给出详细算法思想与源码实现。...
分类:
其他好文 时间:
2015-07-23 10:43:50
阅读次数:
129
10935 Throwing cards awayI Given is an ordered deck of n cards numbered 1 to n with card 1 at the top and card n at the bottom. The following operatio...
分类:
其他好文 时间:
2015-07-22 18:29:38
阅读次数:
182