自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

知之可否

Be yourself; everyone else is already taken.​

  • 博客(30)
  • 资源 (10)
  • 收藏
  • 关注

原创 lintcode: Word Ladder

Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:Only one letter can be changed at a time Each intermediate word must

2016-03-31 17:43:35 599

原创 lintcode:Topological Sorting

Given an directed graph, a topological order of the graph nodes is defined as follow:For each directed edge A -> B in graph, A must before B in the order list. The first node in the order can be any n

2016-03-30 17:27:51 503

原创 lintcode:Combination Sum

Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited number of t

2016-03-29 23:05:02 501

原创 lintcode: Combinations

Given two integers n and k, return all possible combinations of k numbers out of 1 … n.Example For example, If n = 4 and k = 2, a solution is: [[2,4],[3,4],[2,3],[1,2],[1,3],[1,4]]很明显就是一个DFS+回溯的问题;

2016-03-29 17:43:36 437

转载 C++ unique函数

类属性算法unique的作用是从输入序列中“删除”所有相邻的重复元素。该算法删除相邻的重复元素,然后重新排列输入范围内的元素,并且返回一个迭代器(容器的长度没变,只是元素顺序改变了),表示无重复的值范围得结束。// sort words alphabetically so we can find the duplicates sort(words.begin(), words.end());

2016-03-29 15:07:36 1241

转载 一个进程在内存中的布局

值得一提的是:在C#中struct存放在栈区,class存放在堆区,所以一般struct要比class要快的。 堆和栈的比较表(仅针对C++) 栈(Stack)堆(Heap)申请方式由OS自动分配。例如在函数声明一个局部变量int b; OS自动在栈中为b开辟空间需要程序员自己申

2016-03-29 10:00:52 2903

转载 const、static变量存放位置

我们将以下面的例子介绍const变量和static变量的存放位置:static int val_a = 1 ; // 初始化的静态变量 int val_b = 2 ; // 全局变量 const int val_c = 3 ; // const 全局变量 static int val_d ; // 未初始化的静态变量 int val_e ; /

2016-03-29 09:58:05 20084 3

原创 lintcode:Binary Tree Serialization

Design an algorithm and write code to serialize and deserialize a binary tree. Writing the tree to a file is called ‘serialization’ and reading back from the file to reconstruct the exact same binary t

2016-03-28 23:15:21 501

原创 Remove Node in Binary Search Tree

Given a root of Binary Search Tree with unique value for each node. Remove the node with given value. If there is no such a node with given value in the binary search tree, do nothing. You should keep

2016-03-28 21:41:45 745

转载 const指针与指向const对象的指针

1.const指针是一种指针,此指针指向的地址是不能够改变的,但是其指向的对象是可以被修改的,其定义类似: int* const p=地址; 比如下面的代码:int b=12; int* const a=&b; void tes() { *a=1; } 此代码是正确的,先声明了变量b,然后声明一个const指针a,此指针指向变量b,在tes函数中修改

2016-03-28 15:10:41 479

转载 const的用法,特别是用在函数前面与后面的区别!

const的用法,特别是用在函数后面在普通的非 const成员函数中,this的类型是一个指向类类型的 const指针。可以改变this所指向的值,但不能改变 this所保存的地址。 在 const成员函数中,this的类型是一个指向 const类类型对象的 const指针。既不能改变 this所指向的对象,也不能改变 this所保存的地址。关键字:Const,Const函数,Const变量,函数

2016-03-28 15:08:15 8157 2

转载 c++ 函数返回引用

c++ primer p215一,c++函数的返回分为以下几种情况1)主函数main的返回值:这里提及一点,返回0表示程序运行成功。2)返回非引用类型:函数的返回值用于初始化在跳用函数出创建的临时对象。用函数返回值初始化临时对象与用实参初始化形参的方法是一样 的。如果返回类型不是引用,在调用函数的地方会将函数返回值复制给临时对象。且其返回值既可以是局部对象,也可以是求解表达式的结果。3)返回引用:当

2016-03-28 10:22:27 1061

转载 显式构造函数

1.什么是显式构造函数?首先要理解什么是隐式构造函数,并且弄清它的优缺点。#include <iostream>using std::cout;using std::endl;class complexNumbers { double real, img;public: complexNumbers() : real(0), img(0) { } complexNumbers(co

2016-03-28 09:36:43 1538

原创 C++依次读取文件中的字符串——getline()函数的应用

getlime()有着两种形式http://www.cplusplus.com/reference/string/string/getline/ (1) istream& getline (istream& is, string& str, char delim); (2) istream& getline (istream& is, string& str);其中 getline(i

2016-03-23 22:22:21 8048

原创 lintcode: Search Range in Binary Search Tree

Given two values k1 and k2 (where k1 < k2) and a root pointer to a Binary Search Tree. Find all the keys of tree in range k1 to k2. i.e. print all x such that k1<=x<=k2 and x is a key of given BST. Ret

2016-03-22 21:38:50 427

原创 lintcode:Binary Tree Level Order Traversal

Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).Challenge 1: Using only 1 queue to implement it.Challenge 2: Use DFS algorithm to do

2016-03-22 21:10:42 418

原创 lintcode: Construct Binary Tree from Preorder and Inorder Traversal

Given preorder and inorder traversal of a tree, construct the binary tree.我以前的博文已有介绍构造二叉树/** * Definition of TreeNode: * class TreeNode { * public: * int val; * TreeNode *left, *right; *

2016-03-22 20:28:17 318

转载 洗牌算法:随机打乱一组数

扑克牌洗牌是我们生活中比较喜欢玩的一个游戏。那么我们有没有什么办法自己设计一个扑克牌洗牌的方法呢?在c运行库当中有一个随机函数rand,它可以生成0~32767之间的任意数。那么有没有可能利用这么一个函数对我们扑克牌进行随即洗牌呢?    在这里我抛砖引玉一下,谈一谈自己目前已经看到的两个算法。欢迎朋友们谈一谈其他的方法。    (1)全局洗牌法    步骤如下所示:

2016-03-22 15:57:35 2938

原创 lintcode: 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 differ by

2016-03-20 23:04:14 405

原创 lintcode:Validate Binary Search Tree

Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node’s key. The right

2016-03-20 20:34:49 455

原创 lintcode:Binary Tree Preorder Traversal

Given a binary tree, return the preorder traversal of its nodes’ values. Can you do it without recursion? http://www.lintcode.com/en/problem/binary-tree-preorder-traversal/1.递归/** * Definition of Tr

2016-03-17 11:08:55 377

原创 lintcode: Insert Node in a Binary Search Tree

Given a binary search tree and a new tree node, insert the node into the tree. You should keep the tree still be a valid binary search tree. Can you do it without recursion?/** * Definition

2016-03-15 14:38:11 972

原创 lintcode:Convert Sorted List to Balanced BST

Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. http://www.lintcode.com/en/problem/convert-sorted-list-to-balanced-bst/#用快慢指针找出中点,作为根,中点左右

2016-03-14 22:13:01 1060

原创 lintcode:Linked List Cycle

Given a linked list, determine if it has a cycle in it. Given -21->10->4->5, tail connects to node index 1, return true Follow up: Can you solve it without using extra space?1.最基本的方法:复杂度O(n^2)

2016-03-14 11:51:19 296

原创 lintcode:Reorder List

Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes’ values. For example, Given 1->2->3->4->null, reo

2016-03-11 17:01:57 700

原创 lintcode: Reverse Linked List

Reverse a linked list. For linked list 1->2->3, the reversed linked list is 3->2->1 Reverse it in-place and in one-pass最先应该想到的是用栈先依次存储起来,然后弹栈。然而空间复杂度不满足要求。其实,先保存第二个指针的下一个指针,再翻转两个指针之间的指向就可以达到

2016-03-10 10:10:30 475

原创 litcode: Rotate List

Given a list, rotate the list to the right by k places, where k is non-negative. Given 1->2->3->4->5 and k = 2, return 4->5->1->2->3.1、首先要理解这个旋转的意义。 就是倒着数k个node,从那开始到结尾和之前那部分对调,那个例子就是,4->5拿前面

2016-03-09 11:05:36 562

原创 lintcode:Merge Two Sorted Lists

Merge two sorted (ascending) linked lists and return it as a new sorted list. The new sorted list should be made by splicing together the nodes of the two lists and sorted in ascending order. Giv

2016-03-07 15:18:15 367

原创 lintcode: Partition List

Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the nodes in eac

2016-03-07 14:47:54 304

转载 动态开辟二维数组

近日写到一个程序,用到了要动态开辟二维数组,一想,自己就会两种。一者:用new在堆上开辟;二者:用vector开辟。技巧没有多少,但是确实是折腾了我半天!首先,大家去网上搜一下,动态开辟二维数组的文章特别多,再加上我这篇就更多了,我本不想写这篇博文的。但看了网上各位“大虾”“大牛”写的,觉得还是有必要写一下!给各位讲清楚点,以防被网上质量残次不齐的文章误导了。 写文章者,都是学习总结之用!为

2016-03-03 11:44:36 1342

Win7平台VS2010安装Visual Assist X

vs2010适用的破解版vax 编程辅助工具,已验证在win7 和winxp系统均可使用(无论是64bit还是32bit)。注意用破解的DLL覆盖原dll,路径为: (1)如果是Windows7系统: C:/Users/用户名/AppData/Local/Microsoft/VisualStudio/10.0/Extensions/Whole Tomato Software/Visual Assist X/10.7.1901.0 (2)如果是XP系统: C:/Documents and Settings/用户名/Local Settings/Application Data/Microsoft/VisualStudio /10.0/Extensions/Whole Tomato Software/Visual Assist X/10.7.1901.0

2015-03-20

中科大2006-2014年计算机复试机试题

本人是14年考入中科大的计算机研究生。这里面有我做的2006-2014年的全部机试题的代码。 奉献给大家。

2014-09-12

合工大操作系统课程设计:基于内存的文件系统

首先分配一定容量的内存,建立虚拟磁盘; 在该磁盘上建立相应的文件系统; 为该文件系统设计相应的数据结构来管理目录、虚拟磁盘的空闲空间、已分配空间等。 提供文件的创建、删除、移位、改名等功能。 提供良好的界面,可以显示磁盘文件的状态和空间的使用情况; 提供虚拟磁盘转储功能,可将信息存入磁盘,还可从磁盘读入内存; 完全实现了上面的功能,验收的时候老师给了“优”

2013-07-07

北方民族大学试卷(软件工程)

北方民族大学试卷,2010的软件工程导论期末试卷,不容错过哦!

2013-06-10

飞鸽传书简化版代码

一个自己DIY的飞鸽传书JAVA程序,在Eclipse上可以完美的运行,没有任何错误。是课程设计或者毕业设计的最佳选择。4分物超所值。

2013-05-04

合工大单片机考试试卷

合工大单片机考试考试,内部资料,考试和考研最佳选择

2013-04-18

北大ACM答案

不多说,物廉价美,会对你的编程技术大有提高

2013-04-13

数据结构之迷宫游戏课程设计

适合用于课程设计,代码详尽,有图有真相,能够在VC上直接运行

2013-04-13

编译原理课程设计精华合集

有编译原理课程设计的大部分程序的报告,比如递归下降子程序,SLR(1)文法,算法优先表的构造,词法分析,还有算法优先分析的可视化程序.绝对物超所值!

2012-12-05

空空如也

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

TA关注的人

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