自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(38)
  • 资源 (1)
  • 收藏
  • 关注

原创 虚函数:从入门到精通

什么是虚函数C++2011标准(草稿)第10章第3小节给的描述为Virtual functions support dynamic binding and object-oriented programming. A class that declares or inherits a virtual function is called a polymorphic class.If

2014-05-03 16:52:26 979

原创 深度优先遍历与树的前中后序遍历

深度优先遍历深度优先bian

2014-04-24 20:01:48 5270

原创 经典排序算法2-堆排序及优先队列

堆排序以及用堆实现的优先队列#include #include #include #include #include #include #include using namespace std;#define RESET "\033[0m"#define BLACK "\033[30m" /* Black */#define RED "\

2014-04-24 15:32:15 598

原创 经典排序算法

快速排序冒泡排序选择排序桶排序堆排序合并排序

2014-04-24 13:56:21 662

原创 leetcode: Valid Parentheses

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 va

2013-11-26 19:48:59 509

原创 leetcode: Remove Nth Node From End of List

Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the

2013-11-26 19:25:32 497

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

2013-11-26 18:53:54 471

原创 leetcode: Path Sum II

Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and sum = 22, 5 / \

2013-11-24 19:01:09 530

原创 leetcode: Path Sum

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree and sum

2013-11-23 18:51:13 483

原创 leetcode: Longest Common Prefix

Write a function to find the longest common prefix string amongst an array of strings.思路两个两个的比较,然后递归。class Solution {public: string longestCommonPrefix(vector &strs) { // IMPORT

2013-11-23 13:11:57 654

原创 leetcode: Regular Expression Matching

Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input

2013-11-22 16:04:43 967

原创 leetcode: Single Number (II)

Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using ext

2013-11-21 12:25:52 636

原创 leetcode: Integer to Roman

Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.思路同样,注意4和9的处理就行了。仍然是从末位处理比较方便。class Solution {public: string intToRoman(int

2013-11-20 15:29:55 653

原创 leetcode: Roman to Integer

Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.思路很简单,注意4和9的处理就行了。另外,从末位开始计算比较好算,这样可以比较清楚的知道哪一位是阿拉伯数字的哪一位。class Solution {publi

2013-11-20 15:27:38 686

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

2013-11-20 15:21:37 666

原创 leetcode: Palindrome Number

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

2013-11-19 16:05:05 710

原创 webpy的Hello World

http://webpy.org/cookbook/mod_wsgi-apache 测试成功的例子

2013-11-18 21:19:58 1369

原创 Windows 64bit下安装Apache+Python+mod_wsgi+php

apache httpd.conf只要引入php5module,并指定一下phpinidir就行了,php.ini中配置extension_dir最好是绝对路径

2013-11-18 20:20:54 2783

原创 leetcode: String to Integer (atoi)

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-11-17 18:34:09 771

原创 leetcode: Reverse Integer

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 c

2013-11-17 12:40:33 717

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

2013-11-17 12:01:58 838

原创 leetcode: Longest Palindromic Substring

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.思路由于我做题没有按照顺序,前面

2013-11-16 19:23:14 637

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

2013-11-16 16:51:00 658

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

2013-11-16 15:44:48 749

原创 leetcode: 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)).思路本来觉得就是递归,怎么删减一些数字,然后保持问题为剩下一堆

2013-11-14 15:53:36 516

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

2013-10-29 15:37:14 503

原创 排序算法--堆排序

由于不经常使用,之前学习看过的算法都给忘了。现在把他们写下来,记录下来,以方便以后查阅。本篇文章的代码即为堆排序的代码。堆排序代码主函数中是对输入文件中的序列进行排序,并将结果输出到一个文件中。这是一种形式类似于google codejam的测试方法。#include #include using namespace std;void aprint(int *arr,i

2013-10-29 13:37:08 481

原创 leetcode:Longest Consecutive Sequence

problem: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 sequ

2013-05-27 20:51:02 608

原创 leetcode:Sum Root to Leaf Numbers

Problem:Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.

2013-05-25 18:45:40 447

原创 leetcode:Surrounded Regions

Problem:Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region .For example,

2013-05-23 16:44:53 1250

原创 leetcode:Sqrt(x)

题目:Implement int sqrt(int x).Compute and return the square root of x.做这道题目,做的真拙计。一开始想到了《最优化理论》里面的类似于二分法的方法,结果竟然超时。十分不解,后来换成了牛顿切线法,表示貌似我实现的是有问题的,我实现没有使用浮点数,在某些输入的情况下是有死循环的。google了之后,结果让

2013-04-03 19:24:04 1036

原创 leetcode:Palindrome Partitioning

Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [ ["a

2013-03-29 21:13:46 1456

原创 leetcode:Palindrome Partitioning II

谨遵学长教导,开始刷算法题,从leetcode开始做起。可惜第一次就碰到了两个dp的问题Palindrome Partitioning II。。。第一次搞了半天,感觉像是可以建模为最短路径问题,思路不清晰,乱写竟然通过了judge small,在judge large的时候,最后一个测试例子没有通过,显示超时。不懂为什么,后来google了一下,发现原来是判断是不是回文也要用dp,艾。。后来就没有

2013-03-29 19:25:25 2217

原创 Expectation Maximation(EM)算法

最近看论文用到了EM算法,以前也知道它是机器学习中的经典算法之一。于是就仔细研究了一下。作为一个博客新手,无奈于那么多的公式不知道怎么弄,于是就用LaTeX写了pdf上传上来(LaTeX真是个神器),有知道如何在博客中方便输入公式的请不吝赐教。搞了半天发现连上传附件都不会,无奈用下面这个吧。EM算法研究

2012-12-03 13:10:09 825

原创 使用MySQLpp访问MySQL

昨天忘了在看什么的时候发现了在/usr/include/中有个mysql++的文件夹,google之发现原来这个是mysqlpp,一个C++的用来访问MySQL的第三方的库。google到的提供支持的是这个网站http://tangentsoft.net/mysql++/。上面有详细的文档。貌似这个也是有官方支持的,在mysql的官网的emaillist中发现好多关于这个库的。之前也有弄过官网

2012-11-20 10:45:12 5024

原创 C/C++与Python字符串处理比较

本文比较了C,C++和Python中关于字符串处理的一些库函数。这里你可能会奇怪,Python和C/C++本来就不是同一层次上的语言,为什么要放在一起比较。这里就是参照Python来看看C++的字符串处理目前是一种什么情况。Python现在也属于一种很热门的脚本语言,它以其容易上手著称。它的库中提供了众多的函数、类和模块支持对字符串的处理。本文期望能够为使用C++的人提供一定的帮助。在比较值钱

2012-11-13 23:43:02 1783

原创 windows socket端口监听和多线程任务处理

本文本应该是和上一篇在一起的一个程序,但是由于是不同的内容,所以分开来写了。整体思路是将端口监听程序写成一个服务,然后如果遇到服务请求就创建一个新的线程来处理这个请求,在原线程中用一个数组来记录当前所有的请求。本程序在VS2010下测试通过。下面是监听程序,使用非阻塞式socket,使用select来检查是否有请求到来。DWORD CSampleService::ListenThrea

2012-11-05 20:22:14 1050

原创 windows service程序编写及原理

一个windows服务由三部分组成:服务控制管理器,服务本身和服务控制调度器。第一部分是服务控制管理器Service Control Manager(SCM)。每个Windows NT/2000系统都有一个SCM,SCM存在于Service.exe中,在Windows启动的时候会自动运行,伴随着操作系统的启动和关闭而产生和终止。这个进程以系统特权运行,并且提供一个统一的、安全的手段去控制服

2012-11-05 19:42:43 828

EM算法详细例子+推导

这里面有我对EM算法的推导,以及一个详细的例子

2012-12-03

空空如也

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

TA关注的人

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