自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(78)
  • 收藏
  • 关注

原创 leetcode Letter Combinations of a Phone Number

Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit st

2015-05-22 20:47:20 357

原创 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

2015-05-22 15:31:01 374

原创 leetcode Regular Expression Matching

Implement regular expression matching with support for '.' and '*'.Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or mo

2015-05-22 13:13:45 410

原创 leetcode Palindrome Number

Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting the integer to string, no

2015-05-22 10:08:20 396

原创 leetcode Reverse Integer

Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321class Solution {public: int reverse(int x) { bool flag = x < 0 ?0:1; ostri

2015-05-22 02:00:21 325

原创 leetcode ZigZag Conversion

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I

2015-05-22 01:30:27 336

原创 leetcode Median of Two Sorted Arrays

There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).class Solution {publ

2015-05-21 00:53:09 326

原创 leetcode Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo

2015-05-21 00:23:10 275

原创 leetcode Two Sum

Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, whe

2015-05-20 21:37:38 319

原创 leetcode Best Time to Buy and Sell Stock II

Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy on

2015-05-19 12:27:25 343

原创 leetcode Best Time to Buy and Sell Stock

Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),

2015-05-18 21:41:43 336

原创 leetcode Balanced Binary Tree

Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe

2015-05-18 16:27:54 336

原创 leetcode Anagrams

Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.这个是找出所有的回购词#include #include #include #include #include #include

2015-05-18 14:48:40 320

原创 leetcode Add Two Numbers

You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link

2015-05-18 13:53:06 300

原创 leetcode Add Binary

Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".思路:反转在逐位加,在反#include #include #include #include using std::vector;us

2015-05-18 13:01:57 289

原创 leetcode Add and Search Word - Data structure design

很久没刷题,再次面对trie居然没有第一时间想起来Design a data structure that supports the following two operations:void addWord(word)bool search(word)search(word) can search a literal word or a regular express

2015-05-17 21:14:31 365

原创 如何通过模板限制类型

模板的作用是把一组不相关的数据类型作为通用型进行抽象,这样实现泛型。但反过来看如何限制类型呢比如我要限制char类型的生成。这个问题其实可以用模板特化实现。

2014-05-23 21:22:12 1282

原创 排序与设计模式

我们一般在客户端会留统一接口从而动态xuanz

2014-05-19 00:03:31 737

原创 c++求数组大小

每次看到c++的奇技淫巧都觉得这门语言过于复杂庞大,可有时会忍不住去学习,今天学到一个c++判断数组大小,写下做纪念在c中判断数组大小经常用 #define num(x) sizeof(x)/sizeof(0[x])注意这里用0[x]作用是防止自定义类型计算,但我们用一个指针指向一个数组时。比如int a[2];int *p=a;num(p) 计算会得到1,但这不是我们要的结果,既然不是我

2014-03-25 23:44:23 2191

原创 从一个题看python凶残

这几天看python感觉很不适应,刚好有人问一个算法题。我第一思路用c实现一遍,时间复杂度n空间复杂度大点,后想到用python发现python凶残的无语。编写一个函数,实现的功能是在A字符串中没有出现但是在B字符串中出现,把在B字符串中出现的字符保存到字符串U中,并输出字符串U;例如:A字符串“ADCEF",B字符串“gg”,则字符串U是“gg”c代码如下:#include

2014-03-07 13:14:53 644 2

原创 ACMer

There are at least P% and at most Q% students of HDU are ACMers, now I want to know how many students HDU have at least? InputThe input contains multiple test cases.The first line has

2014-01-10 11:33:33 410

原创 Run Away

One of the traps we will encounter in the Pyramid is located in the Large Room. A lot of small holes are drilled into the floor. They look completely harmless at the first sight. But when activated, t

2013-11-09 16:34:28 517

原创 吃糖果

HOHO,终于从Speakless手上赢走了所有的糖果,是Gardon吃糖果时有个特殊的癖好,就是不喜欢将一样的糖果放在一起吃,喜欢先吃一种,下一次吃另一种,这样;可是Gardon不知道是否存在一种吃糖果的顺序使得他能把所有糖果都吃完?请你写个程序帮忙计算一下。 Input第一行有一个整数T,接下来T组数据,每组数据占2行,第一行是一个整数N(0 

2013-11-09 14:19:04 545

原创 敌兵布阵

C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。中央情报局要研究敌人究竟演习什么战术,所

2013-11-09 03:04:40 535

原创 A计划

可怜的公主在一次次被魔王掳走一次次被骑士们救回来之后,而今,不幸的她再一次面临生命的考验。魔王已经发出消息说将在T时刻吃掉公主,因为他听信谣言说吃公主的肉也能长生不老。年迈的国王正是心急如焚,告招天下勇士来拯救公主。不过公主早已习以为常,她深信智勇的骑士LJ肯定能将她救出。现据密探所报,公主被关在一个两层的迷宫里,迷宫的入口是S(0,0,0),公主的位置用P表示,时空传输机用#表示,墙用*表示

2013-11-08 23:25:12 579

原创 下沙小面的(2)

前文再续,书接上一题。话说当上小面的司机的Lele在施行他的那一套拉客法则以后,由于走的路线太长,油费又贵,不久便亏本了。(真可怜~)于是他又想了一个拉客的办法。对于每一次拉客活动,他一次性把乘客都拉上车(当然也不会超过7个,因为位置只有7个)。然后,Lele计算出一条路线(出于某些目的,Lele只把车上乘客的目的地作为这条路线上的站点),把所有乘客都送到目的地(在这路线上不拉上其他乘客)

2013-11-07 13:27:09 469

原创 Anagrams by Stack

How can anagrams result from sequences of stack operations? There are two sequences of stack operators which can convert TROT to TORT: [i i i i o o o oi o i i o o i o]where i stands for

2013-11-06 21:15:44 359

原创 Stars

Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and

2013-11-06 10:35:43 306

原创 Red and Black

There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can'

2013-11-05 19:51:19 368

原创 Oil Deposits

The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides th

2013-11-04 20:02:08 404

原创 Play on Words

Some of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Because there is no other way to open the doors, the puzzle is very impo

2013-11-04 14:15:39 441

原创 What Are You Talking About

Ignatius is so lucky that he met a Martian yesterday. But he didn't know the language the Martians use. The Martian gives him a history book of Mars and a dictionary when it leaves. Now Ignatius want

2013-11-04 10:21:01 584

原创 Zipper

Given three strings, you are to determine whether the third string can be formed by combining the characters in the first two strings. The first two strings can be mixed arbitrarily, but each must sta

2013-11-03 01:20:15 436

原创 最短路

在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt。但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要寻找最短的从商店到赛场的路线,你可以帮助他们吗? Input输入包括多组数据。每组数据第一行是两个整数N、M(N输入保证至少存在1条商店到赛场的路线。 Output对于

2013-11-02 22:33:18 429

原创 搬寝室

搬寝室是很累的,xhd深有体会.时间追述2006年7月9号,那天xhd迫于无奈要从27号楼搬到3号楼,因为10号要封楼了.看着寝室里的n件物品,xhd开始发呆,因为n是一个小于2000的整数,实在是太多了,于是xhd决定随便搬2*k件过去就行了.但还是会很累,因为2*k也不小是一个不大于n的整数.幸运的是xhd根据多年的搬东西的经验发现每搬一次的疲劳度是和左右手的物品的重量差的平方成正比(这里补充

2013-10-31 01:36:37 353

原创 小Q系列故事——最佳裁判

过去的2012年对小Q来说是很悲催的一年,失恋了12次,每次都要郁闷1个来月。  好在小Q是个体育迷,在最痛苦的时候,他常常用观看各种体育节目来麻醉自己,比如伦敦奥运会期间,小Q就常常在周末邀上一群单身同事聚在自己的蜗居,一边畅饮啤酒,一边吹牛。  小Q最喜欢看的是跳水,主要原因也是因为这个项目有中国人参加,而且中国队员获胜的几率很大,一般不会再给自己添堵,不然何谈看体育疗情伤呢。  

2013-10-26 00:54:14 451

原创 郑厂长系列故事——体检

郑厂长不是正厂长  也不是副厂长  他根本就不是厂长  只是公司的一个码农    郑厂长所在的腾讯公司每一年都要组织员工体检,比如量身高体重、测血压之类的,今年也不例外。  这次总共有N位员工接受体检,并且每个员工都需要做K个项目的检查才算完成整个体检的流程。现在来了M个医生为员工做身体检查,并且每一位医生都带齐了检查这K个项目的器材来(也就是说每个医生都能进行这K个项目中

2013-10-26 00:25:00 904

原创 Q系列故事——为什么时光不能倒流

我以为我会是最坚强的那一个 我还是高估了自己  我以为你会是最无情的那一个 还是我贬低了自己  就算不能够在一起 我还是为你担心  就算你可能听不清 也代表我的心意  那北极星的眼泪 闪过你曾经的眼角迷离  那玫瑰花的葬礼 埋葬的却是关于你的回忆  如果时光可以倒流 我希望不要和你分离  如果注定分离 我希望不要和你相遇    ——摘自《小Q失恋日记

2013-10-25 23:08:21 464

原创 湫湫系列故事——减肥记II

虽然制定了减肥食谱,但是湫湫显然克制不住吃货的本能,根本没有按照食谱行动!于是,结果显而易见…  但是没有什么能难倒高智商美女湫湫的,她决定另寻对策——吃没关系,咱吃进去再运动运动消耗掉不就好了?  湫湫在内心咆哮:“我真是天才啊~\(≧▽≦)/~”  可是,大家要知道,过年回家多忙啊——帮忙家里做大扫除,看电影,看小说,高中同学聚餐,初中同学聚餐,小学同学聚餐,吃东西,睡觉,

2013-10-25 21:48:34 509

原创 hdoj 湫湫系列故事——减肥记I

对于吃货来说,过年最幸福的事就是吃了,没有之一!  但是对于女生来说,卡路里(热量)是天敌啊!  资深美女湫湫深谙“胖来如山倒,胖去如抽丝”的道理,所以她希望你能帮忙制定一个食谱,能使她吃得开心的同时,不会制造太多的天敌。  当然,为了方便你制作食谱,湫湫给了你每日食物清单,上面描述了当天她想吃的每种食物能带给她的幸福程度,以及会增加的卡路里量。 Input

2013-10-25 20:28:08 540

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除