自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 递归和非递归方法实现斐波那契数列

介绍斐波那契数列(Fibonacci sequence),又称黄金分割数列、因数学家列昂纳多·斐波那契(Leonardoda Fibonacci[1]  )以兔子繁殖为例子而引入,故又称为“兔子数列”,指的是这样一个数列:0、1、1、2、3、5、8、13、21、34、……在数学上,斐波纳契数列以如下被以递归的方法定义:F(0)=0,F(1)=1,F(n)=F(n-1)+F(n-2)(n≥2

2016-04-13 11:32:56 3290

原创 算法基础——十种常用排序算法的Java及Python实现

概述八大排序算法不用多说了,程序员算法基础必须要掌握的,现在总结一下加深记忆。下图是这八大排序算法的分类、名称、时间空间复杂度,以及稳定性。代码以下是经典八大排序算法的Java及Python代码,都是基于经典算法书籍《算法导论》里的伪代码实现的,我在关键语句部分附上了注释。按照上图中的顺序分别介绍八大排序算法的实现,前面是Java,后面是Python。Java的排序函数写在

2016-04-01 14:58:46 1914

原创 leetcode第24题——**Swap Nodes in Pairs

题目Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant

2016-03-03 09:47:19 1245

原创 leetcode第23题——***Merge k Sorted Lists

题目Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.思路将数组中的k个有序链表归并成一个有序链表,并分析时间复杂度。该题可以在第22题-"merge two sorted lists"的基础上设计算法。一开始想到遍历数组的k-1

2016-03-01 23:11:32 832

原创 leetcode第22题——**Generate Parentheses

题目Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(())

2016-02-29 09:55:52 799

原创 leetcode第21题——*Merge Two Sorted Lists

题目Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.思路把两个有序链表归并成一个有序链表。先用比较笨但很简洁的办法:遍历两个有序链表的节点,比较值

2016-02-28 10:09:15 1215

原创 leetcode第20题——*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

2016-02-27 11:45:43 974

原创 leetcode第19题——*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

2016-02-19 18:47:47 489

原创 leetcode第18题——**4Sum

题目Given an array S of n integers, are there elements a,b, c, and d in S such that a + b +c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note:Ele

2016-01-23 00:13:42 652

原创 leetcode第17题——**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:Digi

2016-01-23 00:10:22 745

原创 leetcode第16题——**3Sum Closest

题目Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have

2016-01-22 14:58:46 619

原创 leetcode第15题——**3Sum

题目Given an array S of n integers, are there elements a,b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triplet (a,

2016-01-20 00:31:54 1351

原创 leetcode第14题——*Longest Common Prefix

题目Write a function to find the longest common prefix string amongst an array of strings.思路寻找字符串数组中所有字符串的最长公共前缀,注意是所有字符串的公共前缀,比如数组['hello', 'hell', 'he']的最长公共前缀为'he'。显然如果存在空字符串则公共前缀为空字符串。可以先将第一个字

2016-01-07 22:29:09 748

原创 leetcode第13题——*Roman to Integer

题目Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.思路这道题是12题逆向思维,事实上比12题要简单一点。我们知道:罗马数字由五个字母组合而成,分别是I(1)、V(5)、X(10)、L(50)、C(100

2016-01-06 22:51:52 1380

原创 leetcode第12题——**Integer to Roman

题目Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.思路题目要求把1-3999的整数转换为罗马数字。只要找出罗马数字各位上的规律,就可以很方便地解出了。个位上的罗马数字(1-9)为'I','II','II

2016-01-06 21:05:21 740

原创 leetcode第11题——**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,

2016-01-06 17:08:02 776

原创 leetcode第10题——***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

2016-01-05 16:07:08 2427 2

原创 tesseract结合selenium快速搜索图片中的文字

大家有没有遇到过这样的问题:当我们看到有些图片中的文字(比如论文中的图片或公式等),想搜索一下,但苦于不能直接复制,只能手动敲入在百度的搜索框;或者碰到其他复制比较麻烦的地方,比如cmd窗口,也是如此.这样费时费力,还可能会输入错误。因此我尝试用python的验证码识别模块tesseract和自动化测试模块selenium写了个很简单的python程序,可以将想要搜索的文字截图下来保存在pyt

2016-01-04 15:55:35 2473

原创 leetcode第9题——*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 convert

2016-01-03 17:20:42 583

原创 leetcode第8题——*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 inpu

2016-01-01 11:07:29 770

原创 leetcode第7题——*Reverse Integer

题目Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321Have you thought about this?Here are some good questions to ask before coding. Bonus points

2015-12-31 20:01:06 467

原创 leetcode第6题——*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

2015-12-31 10:18:32 593

原创 leetcode第5题——**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.思路题目是要求出字符

2015-12-30 11:30:08 601

原创 leetcode第4题——***Median of Two Sorted Arrays

题目There are two sorted arrays nums1 and nums2 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)).思路要求出两个有序数组(长度分别为

2015-12-29 09:52:15 648

原创 leetcode第3题——**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.

2015-12-19 22:56:33 1347

原创 leetcode第2题——**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

2015-12-19 11:28:16 1272

原创 leetcode第1题——**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,

2015-12-19 10:36:13 718

原创 Python实现数据处理——每隔一段时间把数据写入excel文件中

文章介绍在上一篇博文中,我讲述了利用Python的selenium模块抓取动态数据的方法点击打开链接,那么这些抓到的数据如何处理呢?可以写入到excel表格中制成表格,进而画成统计图表直观显示出来。例如按照时间轴统计网站的在线人数,查看哪个时间段人最多,哪个时间段人最少,从而网站维护人员可以按照合适的时间分配资源,用户则可以选择合适的时间访问。要做到以上所述的数据处理,涉及到两个问题:

2015-09-30 17:36:26 18150 2

原创 Python抓取网页动态数据——selenium webdriver的使用

文章目的当我们使用Python爬取网页数据时,往往用的是urllib模块,通过调用urllib模块的urlopen(url)方法返回网页对象,并使用read()方法获得url的html内容,然后使用BeautifulSoup抓取某个标签内容,结合正则表达式过滤。但是,用urllib.urlopen(url).read()获取的只是网页的静态html内容,很多动态数据(比如网站访问人数、当前在线

2015-09-30 16:01:37 32497 1

原创 Linux平台上apache服务器的搭建和应用

背景一次偶然的机会,在实验室下载了一部电影《栀子花开》,在实验室看电影肯定不好吧= = 于是就想拷贝到寝室的电脑回去慢慢看,问题是忘带U盘了,这可就愁了。突然想到,可以在实验室搭建一个apache服务器把电影传到上面,回到寝室下载就行了啊。因为ip肯定都是在校园局域网内的,所以能行得通,而且传输速度也会很理想。搭建服务器1.安装及搭建第一步是在实验室的电脑上安装搭建apache服务

2015-08-29 10:47:06 1999

原创 python输出中文——如何在Windows控制台打印不乱码

文章介绍用Python在控制台打印中文如何不会乱码,一直是困扰很多Pythoner的问题,甚至很多Python老手也经常犯难。原因就在于从一般网页、数据库或文本外来数据源上抓取过来的内容,需要经过正确的编解码才可以正常输出,而Python的编解码机制比较复杂,没有深入思考的话经常遇到调试错误。这篇文章介绍了最常见的几种输出中文的情况,编译平台为Windows控制台,Python版本为2.7.9

2015-08-27 15:40:39 22550

原创 TCP协议增强器的应用实践

1 背景TCP协议增强器,是指将TCP/IP协议栈中传输层的TCP协议进行增强,使之符合一些复杂网络环境的参数要求(如时延、误码率、速率等)的一种应用层软件技术,将TCP协议增强器编译在PC上,可以作为一般网络和复杂网络通信的桥梁,或者说转换网络环境的网关,其应用示意图如下:上图中,客户端如果要访问服务器网页,由客户端发送的连接请求经过GW1增强,成功传输到GW2,然后转换成原

2015-08-23 19:10:26 825

原创 网关监控软件设计与实现

文档目的本文阐述了控制网关中软件的实现,一个是检测和控制MPTCP传输参量的程序。  由于控制网关是Linux平台,根据Linux平台的特点,在Linux内核中已经编译了MPTCP的传输层文件的基础上,本网关软件的研发采用“Shell编程”+“MPTCP配置文件”的方案,从而实现对传输参量的方便可靠监控。程序设计       具体来说,Shell脚本是跟Windows下的批处理

2014-12-29 14:03:48 2452

原创 c++趣味入门——扫雷游戏

阵列中的地雷、数字、空白格与标记格设计用一个二维矩阵代表阵列:元素值统一初始化为-1;随机产生10组坐标,每组坐标对应地雷元素,共10个地雷,并均赋值为9,即地雷的元素值为9;元素值为n(-1元素值为0代表周围没有地雷,挖到该元素时自动显示周围8个元素,如果周围又有个0值元素,递归调用自动显示周围8个元素的方法;如果确认某一元素是地雷,则对其标记并将元素值设为-2,

2014-12-16 16:11:11 14612 1

原创 python进阶——利用网页爬虫写天气预报采集器

在上一篇博文中,博主通过三个游戏程序讲述了python入门知识点击打开链接,现在再讲讲如何利用网页爬虫来写一个天气预报采集器,主要就是在中国天气网上爬取网页并过滤数据,得到需要的天气信息并打印出来。其实要感谢我同学小党,他向我展示了他写的天气预报程序,可以输入城市后显示当前城市的天气和气温。然后我再完善了一下,不仅可以查全国城市的天气情况,也可以查一个省份或直辖市的总体天气情况,如输入“广东”

2014-12-14 15:57:42 7521 2

原创 python趣味入门——写几个常玩的游戏

文档介绍利用python写“猜数字”,“猜词语”,“谁是卧底”这三个游戏,从而快速掌握python编程的入门知识,包括python语法/列表/元组/字典/流程控制/库函数等等。环境参数linux平台,python 3.4。需要在linux中把python 3.4编译一下,这样编写python程序时保存为.py格式的文件并添加执行权限再终端运行即可(原理跟shell脚本相同),非

2014-12-14 14:19:50 59811 7

原创 linux平台中socket通信程序的编写

文档目的博主在搭建好的地面与空间通信的模拟通信网络中,AGW1GW2B之间能够顺利ping通,现在要测试是否能建立TCP连接,开始想直接在B上安装apache服务器,然后A上的浏览器输入B的ip地址可以访问B并下载文件,效果如下:但这样在应用层上是HTTP传输,而且由于对apache内部机制不了解,无法分析传输时的网络层和传输层情况。因此,博主还是倾向于自己用C语言写一个socke

2014-12-13 09:47:39 1931

原创 代理服务器和多径技术实践

利用客户端代理服务器和服务器端反向

2014-10-30 17:04:36 1116 1

原创 用esp开发demo流程

1.环境参数系统:ubuntu 13.10 amd64版本:appweb-5.1.0, esp-5.0.0-rc2(已经搭建好环境,搭建教程可参考http://blog.csdn.net/xiaominthere/article/details/38756421)2.文章目的记录在linux平台的开发esp流程,作为模板便于以后开发其他服务器页面3.流程介绍#cd /hom

2014-10-29 11:42:11 1062 3

空空如也

空空如也

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

TA关注的人

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