刚开始一直WA,一直以为是自己往前延展的时候写错了,后来才发现是ST写错了
+-*/的优先级要比位运算优先级高,以后碰上不清楚优先级的运算一定要加括号
#include
#include
#include
#include
using namespace std;
#define N 100010
char s[N];
int r[N],wa[N],wb[N],wv[N],ws[N],sa...
分类:
其他好文 时间:
2015-04-13 10:59:50
阅读次数:
99
描述:Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest...
分类:
其他好文 时间:
2015-04-12 20:54:09
阅读次数:
137
题目链接:UVA - 10827题意描述:给出一个n*n矩阵,把第一行和最后一行粘一起,把第一列和最后一列粘一起,形成一个环面,求出这个环面中最大的矩阵和。算法分析:首先复制n*n这个矩阵,形成由4个这样小矩阵组成的大矩阵,然后在这个大矩阵里找出最大矩阵和,一看貌似和poj1050这道题有些相似,但...
分类:
其他好文 时间:
2015-04-12 01:14:46
阅读次数:
192
/*最大连续子序列*/class Solution {public: int maxSubArray(int A[], int n) { if(!n) return 0; int result = A[0],temp =0 ; for(int i = ...
分类:
其他好文 时间:
2015-04-11 16:05:23
阅读次数:
116
求一棵树的最大深度 思路:广度优先搜索即可 class Solution {public: int maxDepth(TreeNode *root) { int depth = 0; if (!root) return depth; queue nodeQue; nodeQue.push(root)...
分类:
其他好文 时间:
2015-04-11 11:38:05
阅读次数:
117
给定(可能有负的)整数A1,A2,…,AN,求 的最大值。 例如:输入4,-3,5,-2,-1,2,6,-2,最大子序列和为11(从A1到A7)。 算法1:最直观的算法,穷举式地尝试所有可能。下标变量i表示子序列的开始位置,j表示结束位置,每次选定一个子序列Ai--Aj,再使用k遍历该子序列求子序列...
分类:
其他好文 时间:
2015-04-10 22:21:52
阅读次数:
197
https://leetcode.com/problems/maximum-gap/Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try ...
分类:
其他好文 时间:
2015-04-10 17:45:05
阅读次数:
176
Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from the orig...
分类:
其他好文 时间:
2015-04-10 15:29:31
阅读次数:
161
一:Jump Game
题目:
Given an array of non-negative integers, you are initially positioned at the first index of the array.
Each element in the array represents your maximum jump length at that posi...
分类:
其他好文 时间:
2015-04-10 13:37:59
阅读次数:
197
D. Little Girl and Maximum XOR
A little girl loves problems on bitwise operations very much. Here's one of them.
You are given two integers
l and r. Let's consider the values of
for all pa...
分类:
其他好文 时间:
2015-04-10 09:40:40
阅读次数:
147