- 博客(12)
- 资源 (2)
- 收藏
- 关注
原创 最小的K个数
/****************************************@time 2016/09/25 23:32*@palce dhu.13#.5005*******************************************************/#include#includeusing namespace std;/*****************
2016-09-25 23:35:52 244
原创 数组中超过出现次数超过一半的数字--剑指offer
/****************************************@time 2016/09/25*@palce dhu.13#.5005*******************************************************/#include#includeusing namespace std;/***********************
2016-09-25 23:04:48 259
原创 扔玻璃球
问题描述某幢大楼有N层。你手里有两颗一模一样的玻璃珠。当你拿着玻璃珠在某一层往下扔的时候,一定会有两个结果,玻璃珠碎了或者没碎。这幢大楼有个临界楼层。低于它的楼层,往下扔玻璃珠,玻璃珠不会碎,等于或高于它的楼层,扔下玻璃珠,玻璃珠一定会碎。玻璃珠碎了就不能再扔。现在让你设计一种方式,使得在该方式下,最坏的情况扔的次数比其他任何方式最坏的次数都少。也就是设计一种最有效的方式。解法:/
2016-09-25 19:36:34 1733
原创 KMP字符串匹配
#include#include#includeusing namespace std;void creatNext(char* str,int* next,int len){ next[0]=0; for(int i=1;i<len;i++) { if(str[next[i-1]]==str[i]) { n
2016-09-17 16:45:41 198
原创 Reverse Nodes in k-Group --leetcode
#include#include#include#includeusing namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: ListNode* revers
2016-09-15 23:48:28 301
原创 Generate Parentheses--letcode
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ "((()))", "(()())", "(())()", "()(())
2016-09-15 18:06:08 177
原创 leetcode--Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.Subscribe to see which companies asked this question解法:/********************************************
2016-09-09 13:40:32 204
原创 leetcode-- Container With Most Water
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Fin
2016-09-09 10:35:21 191
原创 leetcode--4Sum
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note: The solution
2016-09-09 09:50:54 193
原创 Leetcode--3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set must not contain
2016-09-07 22:16:46 211
原创 股神
题目描述有股神吗?有,小赛就是!经过严密的计算,小赛买了一支股票,他知道从他买股票的那天开始,股票会有以下变化:第一天不变,以后涨一天,跌一天,涨两天,跌一天,涨三天,跌一天...依此类推。为方便计算,假设每次涨和跌皆为1,股票初始单价也为1,请计算买股票的第n天每股股票值多少钱?输入输入包括多组数
2016-09-07 11:08:32 754
原创 最长回文字符串--manacher算法
/****************************************************@time 2016/09/01 13:49*@place Ctrip.15#.9f*@descrption 马拉车(manacher)算法计算一个字符串中回文字符串的长度,用到了动态规划的思想*****************************************
2016-09-01 14:09:44 283
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人