Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa...
分类:
其他好文 时间:
2015-07-19 10:00:25
阅读次数:
125
二分法+前缀和法律满足子序列长度的条件(0,n)之间,sum[x+i]-sum[i]从i元素开始序列长度x和。前缀和可在O(n)的时间内统计sum[i]的值。再用二分找出满足条件的最小的子序列长度。#include#include#include#include#include#include#in...
分类:
其他好文 时间:
2015-07-18 16:56:42
阅读次数:
116
Common SubsequenceTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 24489Accepted Submission(s): 108...
分类:
其他好文 时间:
2015-07-18 16:49:33
阅读次数:
104
from?https://leetcode.com/problems/sliding-window-maximum/ Given an array?nums, there is a sliding window of size?k?which is moving from the very left of the array to the very right. You can on...
题目:
Sliding Window Maximum
Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the win...
Given an arraynums, there is a sliding window of sizekwhich is moving from the very left of the array to the very right. You can only see theknumbers ...
问题:Arduino:1.6.3 (Windows 7), 板:"Arduino Pro or Pro Mini, ATmega328 (5V, 16 MHz)"Sketch uses 846 bytes (2%) of program storage space. Maximum is 30,72...
分类:
其他好文 时间:
2015-07-18 10:58:20
阅读次数:
593
对于每个元素,最理想的情况就是都在它的左边或者右边,那么sort一下就可以得到一个解了,然后大的中间不能有小的元素,因为如果有的话,那么无论选小的还是选大的都不是最优。对小的元素来说,比它大的元素在哪里是没有关系的。所以把大的看作一个整体,然后插空一下就得出解了。注意llu#include#incl...
分类:
其他好文 时间:
2015-07-18 00:28:41
阅读次数:
141
这个题意是给你n个数,然后寻找一个区间,区间的最大值与最小值的差要小于k并且大于m
思路:
用两个单调序列维护这个序列,显而易见用当前者两个单调序列的列首相减如果大于k的话那么,我们就要寻找列首在序列位置比较小的那个往后面加1。这个题目的难点在于题目意思是区间,我理解错了。以为是那种最长公共子序列那种。
#include
#include
#include
using namespac...
分类:
其他好文 时间:
2015-07-17 18:54:39
阅读次数:
128
??
题意:给定n个数,求两段连续不重叠子段的最大和。
思路很简单,把原串划为两段,求两段的连续最大子串和之和,这里要先预处理一下,用lmax数组表示1到i的最大连续子串和,用rmax数组表示n到i的最大连续子串和,这样将时间复杂度降为O(n)。
#include
#include
#include
#include
#include
#include
#includ...
分类:
其他好文 时间:
2015-07-17 09:59:18
阅读次数:
130