Given a string S, find the longest palindromic substring in S.Note:This is Part II of the article:Longest Palindromic Substring. Here, we describe an ...
分类:
其他好文 时间:
2014-11-12 21:05:22
阅读次数:
345
其实嘞,这个线可以只延伸一端
然后嘞,爆搜一次就可以
最后嘞,600-800ms过
本弱就是弱啊,你来打我呀……
#include
#include
#include
#include
using namespace std;
int a[100][100];
int n,m,ans;
bool dfs(int step)
{
int i,j,t,ii,jj,x,y,cnt,tx...
分类:
其他好文 时间:
2014-11-12 19:48:25
阅读次数:
271
题目:给你n根长度分别为1,2,..,n的棍子,问能组成多少个不同的三角形。
分析:组合数学,计数原理。本题可以正向求解也可以反向求补集,这里采用正向求解。
1.首先写出前几组数据,找规律:{ 里面的括号是子情况 }
(4,3,(2))
(5,4,(3,2))
(6,5,(4,3,2))(6,...
分类:
其他好文 时间:
2014-11-12 16:35:21
阅读次数:
155
问题描述:
Given an integer n, generate a square matrix filled with elements from 1 to
n2 in spiral order.
For example,
Given n = 3,
You should return the following matrix:
[
[ 1, 2, 3 ],
[ 8, 9,...
分类:
其他好文 时间:
2014-11-12 15:06:18
阅读次数:
183
问题描述:
Given a collection of integers that might contain duplicates,
S, return all possible subsets.
Note:
Elements in a subset must be in non-descending order.The solution set must not conta...
分类:
其他好文 时间:
2014-11-12 13:52:10
阅读次数:
184
遇到导入过大文件时,首先检查php.ini 配置文件中的以下三个地方,upload_max_filesize, memory_limit 和post_max_size,并且推荐修改的值要稍大于导入的巨大sql数据库文件;依照这个提示,我修改了以上三个在php.ini中的值以后,重启了php环境(II...
分类:
数据库 时间:
2014-11-12 09:17:41
阅读次数:
155
问题描述:
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-11-11 21:09:06
阅读次数:
207
当有反复元素的时候呢?不用拍脑袋都会想到一种方法,也是全部有反复元素时的通用处理方法,维护一个set,假设这个元素没增加过就增加,增加过了的忽略掉。可是,在这道题上这个通用方法竟然超时了!怎么办?想一下为什么会这样,如果我们要排列的数字是1111112,当当前的排列中没有1时,取哪个1生成一遍,都是...
分类:
其他好文 时间:
2014-11-11 20:41:51
阅读次数:
213
HDU 3081 Marriage Match II
题目链接
题意:n个女孩n个男孩,每个女孩可以和一些男孩配对,然后有些女孩是朋友,满足这个朋友圈里面的人,如果有一个能和某个男孩配对,其他就都可以,然后每轮要求每个女孩匹配到一个男孩,且每轮匹配到的都不同,问最多能匹配几轮
思路:二分轮数k,然后建图为,源点连向女孩,男孩连向汇点容量都为k,然后女孩和男孩之间连边为,有关系的连...
分类:
其他好文 时间:
2014-11-11 19:08:14
阅读次数:
238
题目描述:
Given a linked list, return the node where the cycle begins. If there is no cycle, return null.
Follow up:
Can you solve it without using extra space?
思路:
设置一个快指针fast,一个慢指针slow。快指...
分类:
其他好文 时间:
2014-11-11 16:41:06
阅读次数:
179