- 博客(20)
- 收藏
- 关注
原创 leetcode(11),Power of Three(python)
question:Given an integer, write a function to determine if it is a power of three.Follow up:Could you do it without using any loop / recursion?判断一个数是不是3的冥。进阶:不用循环和递归。循环递归:clas
2016-05-26 23:12:04 512
转载 老中医根治python编码问题2
原地址:http://www.crifan.com/summary_python_2_x_common_string_encode_decode_error_reason_and_solution/【总结】Python 2.x中常见字符编码和解码方面的错误及其解决办法Python 2.x中的字符编码,设计的的确不好,导致初学者,甚至是即使用Python很长时间的人,都会经常
2016-05-25 10:37:49 781
原创 老中医---根治python编码问题(unicode,str等)
最近做爬虫,对编码问题头疼不已,网上看到一篇讲的很到位的博客,彻底根治此疑难杂症。【问题】python中已获取网页:http://blog.csdn.net/hfahe/article/details/5494895的html源码,其时UTF-8编码的。提取出其标题部分:?12345
2016-05-25 10:33:40 1753
转载 机器学习算法---Logistic回归
PDF下载地址:http://download.csdn.net/detail/lewsn2008/65474631.引言看了Stanford的Andrew Ng老师的机器学习公开课中关于Logistic Regression的讲解,然后又看了《机器学习实战》中的LogisticRegression部分,写下此篇学习笔记总结一下。首先说一下我的感受,《机器学习实战》一书在介
2016-05-24 16:57:24 869
原创 leetcode(11), Number of 1 Bits(python)
question:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary repres
2016-05-20 18:31:57 408
原创 leetcode(10),Roman to Integer(python)
question:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.分析:罗马字母是一个个分开的,前十个数是这样I, 1 II, 2III, 3IV, 4V, 5VI, 6VII,
2016-05-16 21:59:35 300
原创 糗百爬虫V2,可爬图片和段子
这个版本是上个爬虫的进化版,可以爬10页热门图片下来,还有些地方没做好,有问题请留言转载请注明,谢谢#-*- coding:utf-8 -*-from bs4 import BeautifulSoupimport urllibimport urllib2import sysreload(sys)sys.setdefaultencoding('utf-8')clas
2016-05-15 15:08:54 722
原创 leedcode(9),Reverse Linked List(python)
question:Reverse a singly linked list.代码如下:class Solution(object): def reverseList(self, head): return self.doReverse(head, None) def doReverse(self, head, newHead): if h
2016-05-13 22:49:01 501
原创 leetcode(8),Majority Element(python)
question:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the ma
2016-05-13 19:11:20 438
原创 leetcode(7),Contains Duplicate(python)
question:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if eve
2016-05-12 11:44:09 308
原创 leetcode(6),Excel Sheet Column Title和Excel Sheet Column Number(python)
Excel Sheet Column Numberquestion:Given a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ... Z ->
2016-05-11 19:30:14 381
原创 leetcode(5),Valid Anagram(python)
question:Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.代码如
2016-05-11 16:40:41 837
原创 leetcode(4),Move Zeroes详解(python)
question:Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], af
2016-05-09 17:31:27 588
原创 leetcode(3),Add Digits详解(python)
question:一个非负整数,将所有位数上的数字相加,得到一个数,如果得数不是个位数,继续相加,直到得数为个位数为止。例入,num=38,3+8=11,1+1=2。写一段代码,计算所有数相加的得数。answer:初级:使用循环或递归解题。def adddigits(num): snum = str(num) count = len(snum) re
2016-05-08 22:39:54 1662
原创 leetcode(2), Nin Game详解(python)
question:桌上有堆石头,有很多个,你和对手轮流拿石头。规则是,每次拿的石头数不能超过三个,也不能不拿,谁先拿完石头谁就获胜。例如:有4个石头,你无论先拿几个,1个2个3个,都会有剩下的让对手一次拿完,这样对方就赢了。现在假设你和对手都很会玩这个游戏,精于计算,需要你根据石头总数,来判断你会不会获胜。解答:首先,一定要注意红色的字,你和对手都精于计算!说明你们都很会玩
2016-05-07 22:25:40 578
原创 机器学习算法---kNN算法
kNN-------k-邻近算法1.kNN是non-parametric分类器,既不做分布式假设,直接从数据估计概率密度;2.kNN不适用于高维数据优点:1.无需估计参数,无需训练;2.特别适合于多分类问题(对象具有多个标签)。缺点:1.当样本容量不平衡是,输入有个新样本,该样本的K个邻值中大容量样本占多数,对分类不利;2.计算量过大,需要计算待分类
2016-05-06 18:55:45 1820
原创 leetcode(1),reverse(python)
question:(将字符串逆向输出)Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".代码实现:def reverse(): string = raw_input(
2016-05-05 19:56:28 341
原创 安装Numpy,Scipy,Matplotlib的步骤及下载地址(亲测有效)
使用python做矩阵计算,离开不了Numpy的使用。Numpy的安装略有些问题,这里把我在安装过程中出现的问题和解决方法供大家参考。1 下载地址地址:http://www.lfd.uci.edu/~gohlke/pythonlibs/这个地址上可以找Numpy,Scipy,Matplotlib的whl,32位64位的都有,比去官网下载方便多了。首先把所有的安装包都下下来。
2016-05-04 22:35:46 3684
原创 初学爬虫,爬取糗百段子(修改版,亲测)
这几天在网上看爬虫教程,有一个教程觉得写得很好,研究了一下,感谢作者做出这么好的教程。原网页地址为:http://blog.csdn.net/column/details/why-bug.html这个代码也是基于原作者爬虫代码修改而来,原网页地址为:http://blog.csdn.net/pleasecallmewhy/article/details/8932310在代码
2016-05-02 22:23:01 1403
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人