自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Python

内置函数locals(): 打印局部变量globals(): 打印全部变量拷贝.copy()是浅拷贝 .deepcopy()是深拷贝

2017-12-22 11:14:56 173

原创 Python_正则表达式

匹配re.match(): 从字符串的头部开始匹配re.search(): 函数将对整个字符串进行搜索,并返回第一个匹配的字符串的match对象。re.findall(): 函数将返回一个所有匹配的字符串的字符串列表。

2017-12-22 10:24:27 123

原创 数据预处理_numpy

生成序列Python 中的range,以及numpy包中的arange函数都可以 两者的区别仅仅是arange返回的是一个数据,而range返回的是list

2017-12-21 15:43:10 408

原创 数据预处理_Pandas

合并表格数据在一些数据处理的情况中,通常需要通过某个关键字合并多个表方法一df_train=pd.concat([res[9],res[10],res[11]],axis=1,ignore_index=True)df_train.columns=['loan_8','loan_9','loan_10']df_train.fillna(0,inplace=True)这种方...

2017-12-21 14:54:27 297

原创 LeetCode题目分类

链表 基于链表的排序: 1.归并排序:先把链表等分成两部分,排序后,然后再把两部分合并回去 2.快速排序:用快慢指针把链表分成两份。 归并K个已排序好的数组: 用堆(优先队列)实现 328. Odd Even Linked List 调整链表的位置,使奇数位置的元素位于偶数位置之前 判断一个链表是否回文 234. Palindrome Linked List 把链表逆转后

2017-11-25 22:17:16 516

原创 LC Problems

Add Two Numbers链表前面的数相当与低位,模拟整数的相加运算public class Solution { public ListNode addTwoNumbers(ListNode l1, ListNode l2) { ListNode c1 = l1; ListNode c2 = l2; ListNode sentinel

2017-10-27 11:15:53 230

原创 算法刷题模板

BFS和DFS题目地址:http://www.lintcode.com/problem/number-of-islands/public void dfs(boolean[][] grid,boolean[][] vis,int i,int j){// vis的访问放在最后面 if(i<0||i>=grid.length||j<0||j>=grid[0].length

2017-08-30 14:47:23 761

原创 二叉树的三种非递归遍历

树的结构struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {}};非递归先序遍历:vector PreorderTraversal(TreeNode* root) {

2017-04-12 19:46:41 224

原创 PAT 甲级:1108. Finding Average

这题的主要难点在于考虑所有非法数字的情况。#include#include#include#include#include#include#include#include#include#includeusing namespace std;const int maxn=1001;bool islegal(string s){ //+-号,多个小数点,小数点后面位数过

2016-11-23 19:47:26 325

原创 PAT 甲级:1105. Spiral Matrix

这道题把N个数从大到小排列,然后按照顺时针的方向,写到一个矩形中。这道题主要是模拟顺时针填满矩形这个过程。这道题的核心在于定义了四个访问的方向,右,下,左,上。 int y[4]={1,0,-1,0}; int x[4]={0,1,0,-1};按照这个方向走,如果遇到边界,则返回上一个访问的点,换一个方向走。所以要写一个边界检测的函数,判断该点是否需要访问。boo

2016-11-23 15:55:50 195

转载 PAT 甲级 1077. Kuchiguse

原来我以为是找N个字符串的最大公共字串,有点懵逼,后来看答案才发现,是公共字串是在最后出现的。然后我也看了答案,就把答案贴上来吧。。。有个陷阱,就是读取字符串的最后可能会有空格。#include#include#include#include#include#include#include#includeusing namespace std;void find

2016-11-22 22:12:29 328

原创 PAT 甲级:1057. Stack

这道题的难点在于在线查询(在查询过程中元素回会发生改变)下面是模仿内存分块存储的思想,分块记录数据。#include#include#include#include#include#includeusing namespace std;//用类似内存读取的分块思想,来加快存储数据的读取const int maxn=100010;const int blocks=316;//每

2016-11-21 20:15:38 241

原创 PAT 甲级 1045. Favorite Color Stripe

第一个算法程序,是暗中按照算法的实现逻辑,用深度优先搜索写的,;。有两个案例没通过,没怎么找bug,就上了。这是我自己写的程序,略繁琐#include#include#include#include#includeusing namespace std;const int max_c=201;//颜色的最大值const int max_l=10010;//原来布条长度的最大值

2016-11-20 19:46:26 216

原创 PAT 甲级 1040. Longest Symmetric String

这个是求字符串的最大回文字串,如果按照动态规划的做法,时间复杂度是o(n^2)这里分享一个时间复杂度为o(n)的做法,因为前不久在leetcode上面看到过,所以做PAT的时候就很快写出来了。#include#include#include#include#includeusing namespace std;const int maxn=1001;char in[maxn]

2016-11-19 21:23:58 281

原创 PAT 甲级 1017. Queueing at Bank

最后一个例子没过不过有巨巨发现我代码的bug,为什么最后一个例子没过,请联系我#include#include#include#includeusing namespace std;int change(int h,int m,int s){ return h*60*60+m*60+s;}struct Cus{ int time; int p;};bool cmp(

2016-11-18 21:38:07 275

原创 PAT 甲级 1014 Waiting in Line (30)

PAT这道题是一道模拟题https://www.patest.cn/contests/pat-a-practise/1014其实逻辑正确,并且注意到几个陷进就能把这道题做出来。下面说说我在做这道题时遇到的陷阱1.输出Sorry的时候一定要输出换行符2.17:00前开始服务的客户,就算到了17:00也可以一直到服务结束银行才关门下面是我的代码#include#inclu

2016-11-18 19:46:45 252

原创 windows环境下scipy与scikit_learn的安装教程(使用pip)

对于学机器学习的同学,sklearn这个包用到的概率是非常大的。在windows环境下安装scipy和sklearn是很麻烦的。下面说说我是如何解决的。由于sklearn依赖于numpy和scipy我首先尝试用pip安装pip install numpy 安装成功但是在pip intall scipy的时候遇到错误。查阅了一些资料。http://www.lfd.uci....

2016-11-15 12:17:38 2680

原创 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.求出最大回文子串,最长子串存在并且唯

2016-10-23 22:14:59 209

转载 leetcode: 97. Interleaving String 递归与DP两种算法

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

2016-10-21 19:20:31 325

转载 leetcode87: Scramble String

Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = "great": great / \ gr

2016-10-21 15:51:09 273

原创 leetcode 85: Maximal Rectangle

题目为计算一个二维矩阵中由1组成的矩形面积。这道题要用动态规划来做,用三个数组来记录一个矩形的信息。left[i,j],左数组记录的是对于i行,j列元素,由他组成的矩形的最左边的1的位置。right[i,j],右数组记录的是对于i行,j列元素,由他组成的矩形的最右边的的1的位置加1。这样直接右边减去左边就是矩形的宽。height[i,j],高素组记录的是对于i行,j列元素,有他组成

2016-10-21 14:38:36 195

转载 leetcode 84:Largest Rectangular Area in a Histogram

对于每个柱子,都有一个关于他的矩形,在这个矩形中,这个柱子是最矮的。只有就算出所有柱子的矩形,再从其中找出最大值,任务就完成了。如何计算柱子"x'作为最短柱子的矩形面积?我们需要找出左边第一个比X小的柱子坐标,和右边第一个比X小的柱子坐标。如何找出左边及右边第一个比X小的柱子呢?我们需要建立一个堆栈,从左到右加入柱子,栈中存放的是柱子的下标,从左到右加入柱子,当加入的柱子i比栈

2016-10-20 20:45:10 301

原创 RiverOfAutumn

可以求得某个词在某种标签中的概率。 再用贝叶斯公式某个词出现,他属于某种标签的概率。 w是一个向量,他的大小是一个包括所有用户搜索词的词集大小 在计算一个用户输入一个搜索词向量是多少时,只需要计算每个标签在w向量是的条件概率,i=1,2…..k,k为标签的个数。 条件概率可以用贝叶斯公式求出。 和很容易求出,只需要遍历所有用户的搜索条就行。 求def trainNB_Gender

2016-10-13 10:22:17 238

原创 leetcode 33. Search in Rotated Sorted Array

Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array retur

2016-10-07 19:37:31 181

转载 java容器

是数组方式下,数组大小需要提前被确定,并不允许修改大小,导致其作为一种灵活的数据容器的能力的功能大为下降。 为了方便的利用数据容器进行引用的管理,Java中提供了丰富的数据容器以满足程序员多样化的需求。JAVA的容器---List,Map,Set Collection ├List │├LinkedList │├ArrayList │└Vect

2016-10-07 15:12:24 226

原创 二叉树非递归的前,中,后序遍历的思考

三种遍历方式的根本区别是Preorder: print parent directly.Inorder: print parent when return from left child.Postorder: print parent when return from right child.可以用堆栈实现非递归遍历而用堆栈实现又有两种方式1.堆栈中存放的是未访问过的结点,

2016-09-20 16:38:53 281

原创 Lecture 5:把无限多个假设降到有限个

Learning is PAC-possible if enough statistical data and finite when M is infinite,we need to estabish a finite quantity that replaces M is effective number of hypotheses always is less than ,

2016-06-03 09:37:37 256

原创 Lecture4: 学习的可能性

Rise the question:Is learning possiblelearning frome D(to infer something outside D) is doomed if any “unknown” f can happen. Because the law learned from inside D would probably show nothing of the l

2016-06-02 20:49:16 350

原创 Lecture3: 不同种类的学习

Learning with different output space1.classification 2.regression 3.structured:such as judging whether a sentence is legalLearning with different reinforcement1.supervised:every comes with correspon

2016-06-02 11:08:16 261

原创 Lecture 2: PLA 演算法

PLA演算法是机器学习中最简单的演算法,它找到一个函数式来模拟输入和输出之间的关系,并且根据找到的点的错误来修正这个函数式。函数式:模拟现实世界的关系 因为是是非问题,所以可以通过正负号来表示输出修正:函数式学习的过程 如果得到的结果W*X和Y结果不同,就进行修正。 比如W*X小于0,说明W和X之间的夹角太大,而正确的Y大于0,所以修正为W+Y*X,使向量转向W和X之间。 如果W*X大于0则

2016-05-31 17:16:28 621

原创 Lecture 1:机器学习初识

1:The Learning Promblem机器学习初识什么是机器学习? 机器学习就是用大量的资料,通过一个算法,训练出一个较为理想的目标函数。这个目标函数必须是未知的,但是有大量的由其产生的相关数据,我们可以根据这些数据来大概地拟合出这个目标函数。

2016-05-31 15:12:40 616

转载 欢迎使用CSDN-markdown编辑器

欢迎使用Markdown编辑器写博客本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦:Markdown和扩展Markdown简洁的语法代码块高亮图片链接和图片上传LaTex数学公式UML序列图和流程图离线写博客导入导出Markdown文件丰富的快捷键快捷键加粗 Ctrl + B 斜体 Ctrl + I 引用 Ctrl

2016-05-31 11:21:39 215

原创 PAT甲级1001. A+B Format (20)

时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueCalculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless

2016-01-01 21:40:57 215

原创 PAT甲级1002. A+B for Polynomials (25)

1001. A+B Format (20)时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueCalculate a + b and output the sum in standard

2016-01-01 21:18:48 207

空空如也

空空如也

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

TA关注的人

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