上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 34 下一页
摘要: Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.You may not alter the values in the nodes, only nodes itself may be changed.Only constant memory is all 阅读全文
posted @ 2013-11-25 22:29 七年之后 阅读(182) 评论(0) 推荐(0) 编辑
摘要: Divide two integers without using multiplication, division and mod operator.思考:位运算。AC的时候真的想说一句“尼玛。。“,用unsigned int 超时,莫名其妙,折腾到半夜,百度一下改为long long过了。。我也不明白到底怎么回事,毕竟不是CS出身,哎。。太晚了,明天再看。VC不支持long long,珍爱生命,远离VC。class Solution {public: int divide(int dividend, int divisor) { // IMPORTANT: Please... 阅读全文
posted @ 2013-11-25 01:49 七年之后 阅读(386) 评论(0) 推荐(0) 编辑
摘要: Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at any point in time.思考:DP方程:dp[i][j]=grid[i][j]+min(dp[i-1][j],dp[i][j-1])。class Solution {public: int... 阅读全文
posted @ 2013-11-23 17:34 七年之后 阅读(161) 评论(0) 推荐(0) 编辑
摘要: Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input string (not partial).The function prototype should be:bool isMatch(const ch 阅读全文
posted @ 2013-11-23 15:23 七年之后 阅读(155) 评论(0) 推荐(0) 编辑
摘要: Write a function to find the longest common prefix string amongst an array of strings.思考:依次比较字符串的第i个字符,不同退出循环。class Solution {public: string longes... 阅读全文
posted @ 2013-11-23 14:47 七年之后 阅读(176) 评论(0) 推荐(0) 编辑
摘要: Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.Whens3="aadbbbaccc", return false.class Solution {private: bool f[1000][1000];public: bool isInterleave(string s1, str 阅读全文
posted @ 2013-11-23 13:37 七年之后 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 描述给出一初始序列a1, a2,...,an,下面有m个操作(x, l, r) : 对于a[l], a[l+1],...,a[r]都加上x. 输出m个操作结束后的序列. 输入第一行两个整数n,m(0 using namespace std;#define maxn 100001int g_count;int n;struct node{ int left; int right; int count;};struct node A[maxn*4];void buildtree(struct node *A,int index,int left,int right){ A[... 阅读全文
posted @ 2013-11-23 10:29 七年之后 阅读(429) 评论(0) 推荐(0) 编辑
摘要: 描述Keroro来侵略地球之前,曾跟Giroro伍长打赌:“我一个人灭掉整个地球给你看!”. 于是Keroro同学真的自己一个人来到地球开始他的侵略行动了。从K隆星出发之前,Keroro从Kururu曹长那儿拿了若干台左手武器{Li}和若干台右手武器{Ri},Keroro需要从{Li}里选一台左手武器,从{Ri}里选一台右手武器,用来组合成可用的恐怖武器。 左右手武器组合的规则很简单,假设从{Li}选出来攻击力为p的武器,从{Ri}选出来攻击力为q的武器,组合起来的攻击力就是p XOR q.Keroro想知道,他能组合成的最强武器攻击力为多少?Hint:必须左右手武器都选出来一个,才能组合成可 阅读全文
posted @ 2013-11-23 10:27 七年之后 阅读(450) 评论(0) 推荐(0) 编辑
摘要: 描述某段时间社会上流行企业收购,而南邮也受此社会风气影响,各个社团到处想着吞并其它社团,以实现扩张势力范围且梦想着统治南邮社团,于是,凶残的“社团吞并风波”就是这样开始了...已知每个社团有两个个属性:势力,标签。 势力代表一个社团的强大能力,任何一个社团只能吞并势力比它小的社团。标签代表该社团是属于什么类型的,一个社团可以有多个标签,如传媒科协有“技术类”,“艺术类”等标签,任意两个社团只有当他们有某一个相同的标签时才能发生吞并。下面C天每天有一次谈判(A,B),表示编号为A的社团和社团B谈判,谈判规则如下: (1)若A,B某一方满足把另一方吞并的所有条件,强大的一方s就会毫不犹豫地把弱的. 阅读全文
posted @ 2013-11-23 10:25 七年之后 阅读(496) 评论(0) 推荐(0) 编辑
摘要: #include#include#include#includeusing namespace std;queueQ;stackS;int *p,n;int f(int a){ int i; int max=a; for(i=a;ip[max]) max=i; } return max;}int main(){// int n; cin>>n; p=new int [n]; int *mark=new int [n]; memset(mark,0,n*sizeof(mark[0])); int i; ... 阅读全文
posted @ 2013-11-23 10:24 七年之后 阅读(565) 评论(0) 推荐(0) 编辑
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 34 下一页