自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(15)
  • 资源 (4)
  • 收藏
  • 关注

原创 CareerCup1.7

Question1.7:Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column are set to 0.1. 遍历一遍,记录下需要置零的行和列2. 对已记录的行和列置零代码:#include #include bool ReadFile(in

2013-02-23 15:35:06 405

原创 CareerCup1.6

Question1.6:Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in place?从最外层到最里层逐层反转顺时针的话:

2013-02-23 15:33:23 404

原创 CareerCup1.5

Question1.5:Implement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa would become a2b1c5a3. If the "compressed" string woul

2013-02-23 15:31:10 441

原创 CareerCup1.4

Question1.4:Write a method to replace all spaces in a string with '%20'. You may assume that the string has sufficient space at the end of the string to hold the additional characters, and that you

2013-02-23 15:29:17 387

原创 CareerCup1.3

Question1.3:Given two strings, write a method to decide if one is a permutation of the other.采用一个256大小的int型数组来计算string中每个char所出现的次数,初始化为0,对第一个string出现一次就+1,对第二个string出现一次就-1遍历完两个string后检查数组中的int

2013-02-23 15:27:00 438

原创 CareerCup1.2

Cracking the Coding Interview 习题1.2:Implement a function void reverse(char* str) in C or C++ which reverses a null-terminated string.定义一个头指针一个尾指针,不停地交换他们指向的元素并且头指针++,尾指针--代码:#include "stdafx.h

2013-02-23 15:23:12 446

原创 CareerCup1.1

Cracking the coding Interview 习题1.1:Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures?代码:#include "stdafx.h"#inclu

2013-02-23 15:18:14 408

原创 寻找最大重复子字符串

来自于CareerCup,原题:Given a string, find the longest substring that occurs more than once. Overlapping is allowed.这道题感觉利用类似于KMP算法比较好,可惜KMP算法不是很熟,更别提根据这道题修改了,先把做法写在这里,等温故了KMP再回来改进:#include

2013-02-15 21:47:33 372

原创 改变链表顺序

出自于CareerCup,原题如下:Suppose that we have a sorted singly linked list with integer values. For example:1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7We want to change the pointers of this linked list so that it b

2013-02-14 21:12:37 689

原创 不使用额外空间字符串去重

题目:要求在不使用额外空间(一两个变量的空间还是允许的)的情况下去除一个string中重复的char,特别使用另外一个大小相当于目标string的数组的额外空间是绝对不允许的。原先想记录下string中出现过的char然后在后面如果有相同的char则去除的,但是这样如果string中重复的较少的话就会使用到较大的额外空间,与题意不符。只能一遍遍的循环判断string中的重复字符并去除。从第

2013-02-11 11:10:53 919

原创 不使用四则运算符计算两数之和

来自于Cracking the Coding Interview,挺有意思的一道题先转换成二进制然后再一位位相加,因为二进制只有0和1所以可以列举各种可能性而不用用到+号,解法如下:#include "stdafx.h"#include #include #include using namespace std;int _tmain(int argc, _TCHAR*

2013-02-10 18:34:27 745

原创 寻找丑数

题目:我们把只包含因子2、3和5的数称作丑数(Ugly Number)。例如6、8都是丑数,但14不是,因为它包含因子7。习惯上我们把1当做是第一个丑数。求出第n个丑数最容易想到的是从1开始依次判断是否为丑数并计数,但基于丑数的增长速度快当n较大时程序的运行效率会非常缓慢。我利用丑数必定是若干个2,3,5的乘积,维护一个顺序的丑数数组,而这个数组的第n个元素即是第n个丑数。

2013-02-09 13:33:32 370

原创 添加最少括号匹配给定括号字符串

同样也是查括号匹配问题是引出的,原题好像是一道ACM吧:给定包含'('')''['']'的一串字符串,要求出至少必须添加多少括号才能让所有括号匹配。知道应该是用动态规划的,但想了很久也没想出做法,最后还是看了别人的分析后才实现的动态规划数组所中的a[i][j]代表的是要让字符串索引从i到j的子字符串中括号匹配所要添加的最少括号数而a[i][j+1]的一种可能是a[i][j]

2013-02-08 19:55:31 2032

原创 判断括号是否匹配

挺简单的问题,判断一串包含'('')''['']'括号的字符串是否匹配,在查打印匹配括号问题时查到的,堆栈好久不用了权当熟悉一下吧:#include #include #include using namespace std;int _tmain(int argc, _TCHAR* argv[]){ string pairstr; cin>>pairstr; sta

2013-02-07 21:02:56 2231

原创 打印匹配括号

开始抽空做一些算法题,留下记录作为菜鸟的成长见证吧。这道题来自于Cracking the Coding Interview, 要求打印n对括号的所有可能匹配。我采用递归来做,这样编写比较方便而且容易弄懂,但用迭代应该会效率快不少而且递归一定能转换成迭代吧,以后有空研究下代码如下:#include "stdafx.h"#include #include #include

2013-02-04 20:20:48 603

irrlicht帮助文档

开源游戏引擎irrlicht的帮助文档,其中提供了个数据结构和函数的用法

2010-07-12

visual studio 样例程序(配合vs文档使用)

配合visual studio 使用的vs样例程序,能够在看文档的同时运行并深入研究样例来加深理解。

2010-04-05

[英文原版计算机信息技术图书].68.Sybex.Complete.Java.2.Certification.Study.Guide.Apr.2005.eBook-DDU.pdf

有名的java2参考书,即适用于java的学习也适用于对于java 2 certification 的准备

2010-04-04

microsoft speech SDK (sapi 5.1) 文档

sapi 5.1 的文档,包括了sapi 5.1 的函数及用法,为speech SDK 的使用提供参考

2010-02-25

空空如也

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

TA关注的人

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