自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

转载 tcpdump详解

简介用简单的话来定义tcpdump,就是:dump the traffic on a network,根据使用者的定义对网络上的数据包进行截获的包分析工具。 tcpdump可以将网络中传送的数据包的“头”完全截获下来提供分析。它支持针对网络层、协议、主机、网络或端口的过滤,并提供and、or、not等逻辑语句来帮助你去掉无用的信息。 实用命令实例默认启动tc

2017-03-05 17:28:17 874

转载 由12306.cn谈谈网站性能技术

12306.cn网站挂了,被全国人民骂了。我这两天也在思考这个事,我想以这个事来粗略地和大家讨论一下网站性能的问题。因为仓促,而且完全基于本人有限的经验和了解,所以,如果有什么问题还请大家一起讨论和指正。(这又是一篇长文,只讨论性能问题,不讨论那些UI,用户体验,或是是否把支付和购票下单环节分开的功能性的东西)业务任何技术都离不开业务需求,所以,要说明性能问题,首先还是想先说说业务问题。

2015-09-12 13:54:47 1089

原创 First Bad Version

You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the

2015-09-09 15:58:30 435

原创 Binary Tree Paths

Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"]/** * Definiti

2015-08-22 16:53:11 538

原创 Course Schedule

There are a total of n courses you have to take, labeled from 0 ton - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a p

2015-07-12 16:05:54 562

原创 Bitwise AND of Numbers Range

Given a range [m, n] where 0 For example, given the range [5, 7], you should return 4.这题如果按照题意做会超时,用移位的操作很妙,因为是并操作,其实只要最小的数和最大的数从左往右取相同的位即可。遇到不同就退出,因为他们中间肯定有数该为为0。class Solution {public:

2015-05-09 01:42:45 828

原创 Number of Islands

Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume

2015-04-13 16:53:59 562

转载 高并发Web服务的演变——节约系统内存和CPU

摘要:现在的Web系统面对的并发连接数在近几年呈现指数增长,高并发成为了一种常态,给Web系统带来不小的挑战。一味地通过增加机器来解决并发量的增长,成本是非常高昂的。结合技术优化方案,才是更有效的解决方法。 【导读】 徐汉彬曾在阿里巴巴和腾讯从事4年多的技术研发工作,负责过日请求量过亿的Web系统升级与重构,目前在小满科技创业,从事SaaS服务技术建设。一、越来

2015-04-05 02:08:01 652

转载 如何处理海量数据

在实际的工作环境下,许多人会遇到海量数据这个复杂而艰巨的问题,它的主要难点有以下几个方面:一、数据量过大,数据中什么情况都可能存在。如果说有10条数据,那么大不了每条去逐一检查,人为处理,如果有上百条数据,也可以考虑,如果数据上到千万级别,甚至 过亿,那不是手工能解决的了,必须通过工具或者程序进行处理,尤其海量的数据中,什么情况都可能存在,例如,数据中某处格式出了问题,尤其在程序处理时,

2015-04-04 17:53:27 916

转载 Linux中的内存管理

前一段时间看了《深入理解Linux内核》对其中的内存管理部分花了不少时间,但是还是有很多问题不是很清楚,最近又花了一些时间复习了一下,在这里记录下自己的理解和对Linux中内存管理的一些看法和认识。我比较喜欢搞清楚一个技术本身的发展历程,简而言之就是这个技术是怎么发展而来的,在这个技术之前存在哪些技术,这些技术有哪些特点,为什么会被目前的技术所取代,而目前的技术又解决了之前的技术所存在的哪

2015-04-01 10:11:02 392

转载 深入理解内存地址

事物的发展总是从简单到复杂,当然我们学习应该是先从简单到复杂学习,然后慢慢思考融汇贯通,最后又把复杂化为简单.我们先来看看在计算机刚出来不久内存是怎么被使用,然后随着技术的发展又是怎么演化的.当然这里的描述只是简单化的体现下那种思想,很多细节未必准确. 简单的历史故事1.单用户使用内存刚开始的时候电脑功能相当简单,而且用电脑的也都是些高手专家,对硬件相当的了解.此时也没有啥操作

2015-03-24 02:16:17 2334

转载 Linux内存管理

摘要:本章首先以应用程序开发者的角度审视Linux的进程内存管理,在此基础上逐步深入到内核中讨论系统物理内存管理和内核内存的使用方法。力求从外到内、水到渠成地引导网友分析Linux的内存管理与使用。在本章最后,我们给出一个内存映射的实例,帮助网友们理解内核内存管理与用户内存管理之间的关系,希望大家最终能驾驭Linux内存管理。前言 内存管理一向是所有操作系统书籍不惜笔墨重点讨论的内容,

2015-03-22 17:39:56 512

原创 C++构造函数执行顺序

实践是真知的唯一标准啊#include #include using namespace std;class V {public: V(){ printf("V constructor.....\n"); } V(int k) { printf("V %d constructor.....\n", k); } ~V() { printf

2015-03-22 16:34:24 629

转载 new和malloc

1. malloc()函数1.1 malloc的全称是memory allocation,中文叫动态内存分配。原型:extern void *malloc(unsigned int num_bytes); 说明:分配长度为num_bytes字节的内存块。如果分配成功则返回指向被分配内存的指针,分配失败返回空指针NULL。当内存不再使用时,应使用free()函数将内存块释放。1.2

2015-03-22 02:51:56 359

转载 nginx架构

众所周知,nginx性能高,而nginx的高性能与其架构是分不开的。那么nginx究竟是怎么样的呢?这一节我们先来初识一下nginx框架吧。nginx在启动后,在unix系统中会以daemon的方式在后台运行,后台进程包含一个master进程和多个worker进程。我们也可以手动地关掉后台模式,让nginx在前台运行,并且通过配置让nginx取消master进程,从而可以使nginx以单进

2015-03-21 21:31:04 409

原创 线程安全的单例模式

一、懒汉模式:1、静态成员实例的懒汉模式:class Singleton{private: static Singleton* m_instance; Singleton(){}public: static Singleton* getInstance();};Singleton* Singleton::getInstance(){ if(

2015-03-20 11:06:48 618

转载 tcp/ip状态图

收藏注:主动、被动 与 服务器、客户端没有明确的对应关系。这个图N多人都知道,它排除和定位网络或系统故障时大有帮助,但是怎样牢牢地将这张图刻在脑中呢?那么你就一定要对这张图的每一个状态,及转换的过程有深刻的认识,不能只停留在一知半解之中。下面对这张图的11种状态详细解析一下,以便加强记忆!不过在这之前,先回顾一下TCP建立连接的三次握手过程,以及关闭连接的四次握手过程。1、建立

2015-03-19 21:59:20 556

转载 理解inode

作者: 阮一峰日期: 2011年12月 4日 inode是一个重要概念,是理解Unix/Linux文件系统和硬盘储存的基础。我觉得,理解inode,不仅有助于提高系统操作水平,还有助于体会Unix设计哲学,即如何把底层的复杂性抽象成一个简单概念,从而大大简化用户接口。下面就是我的inode学习笔记,尽量保持简单。=========================

2015-03-16 17:14:30 373

转载 http协议

Author :Jeffrey My Blog:http://blog.csdn.net/gueter/ 引言                                       HTTP是一个属于应用层的面向对象的协议,由于其简捷、快速的方式,适用于分布式超媒体信息系统。它于1990年提出,经过几年的使用与发展,得到不断地完善和扩展。目前在WWW中使用的是HT

2015-03-14 00:44:20 401

原创 Add Binary

Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".不难,考细节class Solution {public: string addBinary(string a, string b) {

2015-03-11 20:14:39 630

原创 Count and Say

The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as "one 2

2015-03-09 15:09:27 514

原创 strcpy的实现

要考虑内存重叠char * strcpy(char *dst,const char *src){ assert(dst != NULL && src != NULL); char *ret = dst; my_memcpy(dst, src, strlen(src)+1); return ret;}char *my_memcpy(char *dst,

2015-03-09 13:21:07 581

原创 Decode Ways

A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total number

2015-03-09 01:35:47 678

原创 Implement strStr() && kmp算法

用这题复习下kmp算法。kmp网上坑爹的是有很多种匹配方式,容易混淆,后人要警惕啊。这里对要查找的字符串的next全部置为-1,预处理时i和next[i-1]+1相比较。和http://kb.cnblogs.com/page/176818/ 这里相似。预处理完再匹配,第i个字符不匹配则比较第next[i-1]+1个。class Solution{ public: cha

2015-03-07 21:50:03 558

原创 Interleaving String

Given s1, s2, s3, find whether s3 is formed by the interleaving ofs1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc", return

2015-03-07 15:39:26 519

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

2015-03-07 00:29:27 713

原创 Multiply Strings

字符串的相乘,可用于解决大数相乘,注意首尾颠倒class Solution {public:string multiply(string num1, string num2) { if(num1 == "0" || num2 == "0") return "0"; int l1 = num1.length(), l2 = num2.length(); i

2015-03-01 19:54:22 586

转载 大型网站架构演变过程、大并发服务器架构

大型网站架构演变过程:[Step1]web server与数据库分离web动静资源分离静态请求:如html, js, css, img动态请求:如jsp, php[Step2]缓存处理客户端(浏览器)缓存前端页面缓存(squid)页面片段缓存ESI(Edge Side Includes)

2015-02-22 13:14:03 449

原创 Valid Number

判断是否数字,考虑多种情况class Solution{public: bool isNumber(string s){ int i = 0; while(s[i] == ' ') ++i; while(s[i] == '+' || s[i] == '-') ++i; bool exp = false, space = false, point = fa

2015-02-13 15:23:35 500

原创 Vector类的实现

实现部分vector的类template class Vector{public: explicit Vector(int initSize = 0) :theSize(initSize), theCapacity(initSize+SPARE_CAPACITY){ objects = new Object[theCapacity]; } Vector

2015-02-05 10:37:27 648

转载 socket 的通信过程

下图是基于TCP协议的客户端/服务器程序的一般流程:服务器调用socket()、bind()、listen()完成初始化后,调用accept()阻塞等待,处于监听端口的状态,客户端调用socket()初始化后,调用connect()发出SYN段并阻塞等待服务器应答,服务器应答一个SYN-ACK段,客户端收到后从connect()返回,同时应答一个ACK段,服务器收到后从accept

2015-02-01 00:04:07 468

原创 Dungeon Game

The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially pos

2015-01-30 22:42:27 591

原创 Find Minimum in Rotated Sorted Array I && II

这些题比较考验边界条件Find Minimum in Rotated Sorted Array class Solution {public: int findMin(vector &num) { int left = 0, right = num.size()-1; while(num[left] > num[right]){

2015-01-30 18:40:38 574

原创 Median of Two Sorted Arrays

There are two sorted arrays A and B 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)).用二分的方法求合并数组的中值。用找第k大的值来求,不断去掉较小的一半,

2015-01-29 11:20:45 593

原创 Search a 2D Matrix

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each

2015-01-29 00:36:28 608

原创 Search for a Range

Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the target is not found in

2015-01-29 00:22:23 582

原创 Search in Rotated Sorted Array I && II

对翻过一次的排序数组二分查找,要利用好已排序这个条件class Solution {public: int search(int A[], int n, int target) { int left = 0, right = n-1; while(left <= right){ int mid = (left+right)/2

2015-01-28 16:20:02 575

原创 Balanced Binary Tree

检测一个树是否平衡,不需要求出高度,而是从底到顶检测是否平衡,这样才算法时间复杂度为O(n)。但是需要额外的O(logn)的空间/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(

2015-01-27 21:19:31 539

原创 Binary Search Tree Iterator

Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.Note: next() and

2015-01-27 21:07:19 560

原创 Binary Tree Maximum Path Sum

Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.求树的一点到另一点的最大路径,利用递归的方法,ans 在 左子树,右子树,root+左+右的最大中产生。/** * Definition for binary tree * struct

2015-01-27 20:24:19 545

空空如也

空空如也

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

TA关注的人

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