自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(72)
  • 资源 (2)
  • 收藏
  • 关注

转载 Git 的origin和master分析

首先要明确一点,对git的操作是围绕3个大的步骤来展开的(其实几乎所有的SCM都是这样)1.     从git取数据(git clone)2.     改动代码3.     将改动传回git(git push)这3个步骤又涉及到两个repository,一个是remote repository,再远程服务器上,一个是local repository,

2014-02-12 14:49:41 737

原创 ubuntu12.04.2 安装erlang

wget http://www.erlang.org/download/otp_src_R16B03-1.tar.gztar xzf otp_src_r16B03-1.tar.gzwget https://sourceforge.net/projects/wxwindows/files/3.0.0/wxWidgets-3.0.0.tar.bz2/downloadtar xjf down

2014-01-28 22:29:45 991

原创 锯齿状层次化输出二叉树

/*given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary t

2013-10-07 23:33:04 693

原创 字符串解析出所有ip地址

/*given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255.11.135", "255.255.111.35"]. (Order does

2013-10-07 17:05:18 1759

原创 二叉树层次遍历

/*given a binary Tree Level Order Traversal AC Rate: 950/3041 My SubmissionsGiven a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For

2013-10-07 15:08:41 582

原创 相似字符串(字符串编辑)最短距离(非递归版本)

第一次写的递归版本:点击打开链接,速度太慢了,基本case都超时,重新写一个非递归的/*given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have th

2013-10-07 13:59:19 574

原创 最长非重复字串

/*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 i

2013-10-06 21:31:50 522

原创 最长回文子串

/*given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.*/#include #include

2013-10-06 21:11:29 542

原创 带有随机指针的链表拷贝

#include #include struct RandomListNode{ int label; RandomListNode *next,*random; RandomListNode(int x):label(x),next(NULL),random(NULL) { }};class Solution{public: RandomListNode* copy

2013-10-06 16:08:59 799

原创 最长连续序列(O(n),C++版)

/*given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example, Given [100, 4, 200, 1, 3, 2], The longest consecutive elements sequence is [1, 2, 3

2013-10-06 13:35:42 1009

转载 最长连续序列(O(n)算法)

原文出处:点击打开链接/***************************************************************************** * File: LongestRange.java * Author: Keith Schwarz (htiek@cs.stanford.edu) * * An algorithm for finding t

2013-10-06 12:51:29 783

原创 括号的有效性

/*Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all valid

2013-10-06 12:27:45 613

原创 反转整数

/*reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Have you thought about this?Here are some good questions to ask before coding.

2013-10-05 23:17:02 628

原创 aoti重新写

/*implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input ca

2013-10-05 23:02:35 660

原创 矩阵最短路径

/*ven 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 a

2013-10-05 15:44:10 789

原创 Same tree

/*Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.*/#include

2013-10-05 15:42:57 553

原创 加油站问题

/*There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to it

2013-10-05 14:45:14 800

原创 数组中和为N的组合

/**现有整型数组y{1,2,4,3,5,8},写出一个函数,找出所有和为10的集合**/#include #include #include void print(std::vector& vec){ if(!vec.empty()) { std::for_each(vec.begin(),vec.end(),[](const int& val) { std:

2013-10-04 15:23:10 2607

原创 linux线程结束

Linux下线程有三种结束的方法:1. 线程函数执行完毕,线程正常结束;2. 线程调用pthread_exit(void* rval_ptr)3. 线程被取消(也就是其他线程调用pthread_cancel(pthread_t)这里主要总结一下线程调用pthread_exit和pthread_cancel结束的问题。一. 线程被取消:线程被取消,就是其他线程调用pthrea

2013-09-19 18:12:43 1681

原创 linux作业管理相关信号

SIGHUP:     SIGHUP信号在如下情况下会发生:     1. 控制终端关闭,此时会发送SIGHUP给会发送给session首进程以及几个后台进程组;     2. session首进程退出,此时会发送给前端进程组的每一个进程;     3.如果进程组的首进程推出,该进程组成为孤儿进程组,并且进程组中有进程处于停止状态(如发送SIGSTOP或者SIGTSTP),则先发送

2013-09-16 20:28:33 712

原创 判断一个序列是不是另外一个序列的栈的pop序列

/**题目:输入两个整数序列。其中一个序列表示栈的push顺序,判断另一个序列有没有可能是对应的pop顺序。为了简单起见,我们假设push序列的任意两个整数都是不相等的。 比如输入的push序列是1、2、3、4、5,那么4、5、3、2、1就有可能是一个pop系列。因为可以有如下的push和pop序列:push 1,push 2,push 3,push 4,pop,push 5,p

2013-09-10 21:44:22 698

原创 台阶问题

/**题目:一个台阶总共有n级,如果一次可以跳1级,也可以跳2级。求总共有多少总跳法,并分析算法的时间复杂度。**/#include #include unsigned long long stage(size_t n){ if(n==1 || n==2) return n; unsigned long long a1=1; unsigned long long a2

2013-09-10 20:17:04 531

原创 图的邻接表实现以及targan算法

/*点类*/#ifndef NODE_H__#define NODE_H__#include "arc.h"#include #include struct node{ std::string node_name; std::shared_ptr arc; node() { node_name.clear(); arc.reset(); } node(con

2013-09-10 19:58:28 843

原创 shared_ptr使用,构建list

节点类:/**link list node**/#ifndef NODE__H__#define NODE__H__#include templateclass node{public: T val; std::shared_ptr next;public: node() { next.reset();

2013-09-10 16:01:42 1285

原创 atoi

/**题目:输入一个表示整数的字符串,把该字符串转换成整数并输出。例如输入字符串"345",则输出整数345。**/#include #include #include int atoi(char* src,size_t size){ if(src==NULL || size==0) throw std::exception("parameter error!"); i

2013-09-09 22:06:51 611

原创 约瑟夫环问题

/**题目:n个数字(0,1,…,n-1)形成一个圆圈,从数字0开始,每次从这个圆圈中删除第m个数字(第一个为当前数字本身,第二个为当前数字的下一个数字)。当一个数字删除后,从被删除数字的下一个继续删除第m个数字。求出在这个圆圈中剩下的最后一个数字。**/#include #include //循环队列法void joseph_with_queue(int n,int k)

2013-09-09 19:19:17 563

原创 求已排序数组中和为某个数的两个数

/**题目:输入一个已经按升序排序过的数组和一个数字,在数组中查找两个数,使得它们的和正好是输入的那个数字。要求时间复杂度是O(n)。如果有多对数字的和等于输入的数字,输出任意一对即可。例如输入数组1、2、4、7、11、15和数字15。由于4+11=15,因此输出4和11。**/#include void solve(int* arr,int size,int val){ i

2013-09-09 15:29:02 622

原创 求的数组的topN

/**查找最小的k个元素题目:输入n个整数,输出其中最小的k个。例如输入1,2,3,4,5,6,7和8这8个数字,则最小的4个数字为1,2,3和4**/#include #include #include //swapvoid swap(int& left,int& right){ int tem=left; left=right; right=tem;}//sh

2013-09-09 14:50:53 1178

原创 二叉树中查找和为某个数的所有路径

/*题目:输入一个整数和一棵二元树。从树的根结点开始往下访问一直到叶结点所经过的所有结点形成一条路径。打印出和与输入整数相等的所有路径。例如 输入整数22和如下二元树 10 / \ 5 12 / \ 4 7则打印出两条路径:10, 12和10, 5, 7。*/#include #include #include struct btree

2013-09-09 14:09:08 727

原创 最大子串和

/**输入一个整形数组,数组里有正数也有负数。数组中连续的一个或多个整数组成一个子数组,每个子数组都有一个和。求所有子数组的和的最大值。要求时间复杂度为O(n)。例如输入的数组为1, -2, 3, 10, -4, 7, 2, -5,和最大的子数组为3, 10, -4, 7, 2,因此输出为该子数组的和18。**/#include #include #include int

2013-09-09 13:51:18 519

原创 二叉树搜索树转双链表

/*1.把二元查找树转变成排序的双向链表 题目:输入一棵二元查找树,将该二元查找树转换成一个排序的双向链表。要求不能创建任何新的结点,只调整指针的指向。 10 / \ 6 14 / \ / \4 8 12 16 转换成双向链表4=6=8=10=12=14=16*/#include struct btree_node{ int val;

2013-09-09 13:38:04 639

原创 满足min.push.pop操作时间复杂度为o(1)的栈

/**设计一个栈结构,满足一下条件:min,push,pop操作的时间复杂度为O(1)。*/#include #include #include class stack{public: stack(int max_size) { this->max_size=max_size; this->cur_size=0; this->cur_min=std::numeri

2013-09-08 22:48:16 976

原创 百度--包含所有珠子的最小串

/**一串首尾相连的珠子(m个),有N种颜色(N<=10),设计一个算法,取出其中一段,要求包含所有N中颜色,并使长度最短。并分析时间复杂度与空间复杂度。*/#include #include #include #include class state{public: state(std::string str) { this->str=str; sum=0;

2013-09-08 17:49:22 634

原创 上交硕士上机题

/*1 2 3 4 5 67 8 9 0 说某移动电信运营商开发了一个名为“争霸”的游戏,为鼓励用户参与,凡签约用户均可获得前三位为888的手机号码,但这样的话就有10的8次方种可能,现在给出一种限制条件减少号码数量,就是两个相邻号码之间的关系必须满足象棋里的“将步”即:给你前三位都是888 后面8位是上面的数字 每个数的相邻只有有限个数字比如8881*

2013-09-08 16:56:07 603

原创 腾讯-字符串匹配

讨论帖地址:点击打开链接/*假设两个字符串中所含有的字符和个数都相同我们就叫这两个字符串匹配, 比如:abcda和adabc,由于出现的字符个数都是相同,只是顺序不同, 所以这两个字符串是匹配的。要求高效!*/#include #include bool match_string(char* left,char* right,int n){ if(left==NULL || r

2013-09-08 15:42:32 519

原创 华为笔试题2

/*给定一个数组input[] ,如果数组长度n为奇数,则将数组中最大的元素放到 * output[] 数组最中间的位置,如果数组长度n为偶数,则将数组中最大的元 * 素放到 output[] 数组中间两个位置偏右的那个位置上,然后再按从大到小 * 的顺序,依次在第一个位置的两边,按照一左一右的顺序,依次存放剩下的数。 * 例如:input[] = {3, 6, 1, 9, 7} ou

2013-09-07 22:39:47 608

原创 华为机试第一题

/* * 选秀节目打分,分为专家评委和大众评委,score[] 数组里面存储每个评委打的分数 * judge_type[] 里存储与 score[] 数组对应的评委类别,judge_type[i] == 1,表示专家评委, * judge_type[i] == 2,表示大众评委,n表示评委总数。打分规则如下:专家评委和大众评委的 * 分数先分别取一个平均分(平均分取整),然后,总分 = 专

2013-09-07 22:24:15 771

转载 KMP算法由浅入深(经典!)

KMP算法,是由Knuth,Morris,Pratt共同提出的模式匹配算法,其对于任何模式和目标序列,都可以在线性时间内完成匹配查找,而不会发生退化,是一个非常优秀的模式匹配算法。但是相较于其他模式匹配算法,该算法晦涩难懂,第一次接触该算法的读者往往会看得一头雾水,主要原因是KMP算法在构造跳转表next过程中进行了多个层面的优化和抽象,使得KMP算法进行模式匹配的原理显得不那么直白。本文希望能够

2013-09-07 21:54:38 652

原创 linux权限计算

/*现在有一数组中存放着 1、2、4、8这四个固定的数字 所有数字不能重复我想封装一个函数 输入一个数字 找出这个数字是由哪几个数字组成的比如:输入7 找出的数字是1、2、4输入15 找出的数字是1、2、4、8*/#include void permit(int n){ for(int i=0;i<4;++i) { if(n&(1<<i)) std::cout<<

2013-09-06 13:12:04 720

原创 strcmp和strcpy

char* strcpy(char* dst, char* src, size_t len){ char* d=dst; while((--len)&&(*dst++=*src++)); //方向不可互换 *dst='\0'; return d;}int strcmp(char* src,char* sub){ while((*src)==(*sub++)) if((*sr

2013-09-03 20:12:34 509

c++名家对话 chm格式 经典书籍

chm格式,采用对话的形式,结合使用经验,讲解c++的经典技术

2009-11-21

网络刺客2:端口扫描工具

这个端口扫描工具很好用,大家试试 哎,还得多说废话,才让上传,这郁闷

2009-08-18

空空如也

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

TA关注的人

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