自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Eliza1130的专栏

请多指教

  • 博客(68)
  • 收藏
  • 关注

转载 python的正则表达式re模块的常用方法

python的正则表达式re模块的常用方法作者: 字体:[增加 减小] 类型:转载 Python 的 re 模块(Regular Expression 正则表达式)提供各种正则表达式的匹配操作,在文本解析、复杂字符串分析和信息提取时是一个非常有用的工具,下面我主要总结了re的常用方法1.re的简介 使用python的re模块,尽管不能满足所有

2015-04-16 21:44:54 1601

转载 python 表情过滤

注意替换的这些emoji是标准的表情字符,每个表情本来是2个字节,替换成字符串后,每个表情就变成12个字符了,浪费了很多空间,不过简单,不需要专门写个map一一对应了; 把表情变成字符串?123456789deffilter_emoji(desstr,re

2015-04-14 19:45:51 2736

原创 bigram分词

N-gram:P(w1w2w3...wn)=P(w1)P(w2|w1)P(w3|w2,w1)...P(wn|wn-1,wn-2,...,w1)

2015-04-14 12:11:50 7020

原创 hive的简单使用说明

I使用:hive:启动hive命令必须以分号结束,告诉hive立即执行该命令,不区分大小写show tables;查看有哪些表desc tablename; 查看表有哪些列写sql命令use udw;select user_id,action_idfrom udw_ml_user_actionwhere partition_date>=20150410dis

2015-04-14 10:44:36 1079

原创 leetcode_num101_Symmetric Tree

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the f

2015-04-04 22:49:58 785

原创 leetcode_num95_Unique BT II

Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1 3

2015-04-04 17:17:02 845

原创 leetcode_num98_Validate Binary Search Tree

判断是否为二叉搜索树定义上下确界/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} *

2015-04-01 22:40:18 615

原创 leetcode_num179_Insertion Sort list

Sort a linked list using insertion sort.举例子真是写对代码的好方法!/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NU

2015-04-01 21:54:16 668

原创 leetcode_num179_Largest Number

Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.两两比较 可以利用sort函数来排序,自定义comp

2015-04-01 19:22:55 715

原创 leetcode_num75_sort colors

Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers

2015-04-01 11:01:01 791

原创 leetcode_num148_Sort list

链表的归并排序特别注意取中值函数的书写/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {

2015-03-30 19:57:09 793

原创 leetcode_num155_Min Stack

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get

2015-03-30 16:24:40 715

原创 leetcode_num6_Zigzag

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

2015-03-27 18:23:38 709

转载 python操作Excel读写--使用xlrd

一、安装xlrd模块   到python官网下载http://pypi.python.org/pypi/xlrd模块安装,前提是已经安装了python 环境。windows环境下,将解压后的xlrd文件夹复制至python安装目录下二、使用介绍  1、导入模块      import xlrd   2、打开Excel文件读取数据   

2015-03-27 11:09:19 867

原创 螺旋矩阵2——顺时针打印任意大小的矩阵

#includeusing namespace std;void PrintCircle(int **matrix,int start,int row,int column){ int endX=column-1-start; int endY=row-1-start; for(int i=start;i<=endX;i++){ cout<<matrix[start][i]<<'

2015-03-22 11:39:41 953

原创 leetcode_num165_Compare Version numbers

Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0.class Solution {public: int compareVersion(string ver

2015-03-18 23:41:20 564

原创 层序遍历及其进阶版

输入为:abd##eh###cfi##j##g##1、普通层序遍历:输出为一行2、进阶版1:输出每一层,从左向右依次输出3、进阶版2:S型输出每一层,即从右向左和从左向右交替输出#include#includeusing namespace std;templatestruct BiNode { T data; BiNod

2015-03-18 18:50:49 927 1

原创 螺旋矩阵——正逆序

输入数字N,输出大小为N*N的螺旋矩阵#includeusing namespace std;void Spiral_Matrix1(int N,int **r){//正序输出 int k=N;int sum=1; while(k>0){ int m=(N-k)/2; int i=m,j=m; if(k==1){ //奇数情况下 r[m][m]=sum; br

2015-03-17 16:27:56 1278 2

转载 指针和引用的区别

总结一下指针和引用的相同点和不同点:★相同点:●都是地址的概念;指针指向一块内存,它的内容是所指内存的地址;而引用则是某块内存的别名。★不同点:●指针是一个实体,而引用仅是个别名;●引用只能在定义时被初始化一次,之后不可变;指针可变;引用"从一而终",指针可以"见异思迁";●引用没有const,指针有const,const的指针不可变;(具体

2015-03-12 20:14:30 574

原创 排序算法总结(三)逆序对

求数组中的逆序对#includeusing namespace std;int MergeArray(int r[],int s,int m,int e,int temp[]){ int i=m,j=e,count=0,k=0; while(i>=s&&j>=m+1){ if (r[i]>r[j]){ temp[k]=r[i]; k++; count=count+

2015-03-12 10:57:51 1370

原创 排序算法总结(二)归并法

递归法#includeusing namespace std;void Merge(int r[],int r1[],int b,int m,int e){ int i=b; int j=m+1; int k=b; while((i<=m)&&(j<=e)){ if(r[i]<=r[j]){ r1[k]=r[i]; i++; k++;} else{ r1[k

2015-03-12 10:56:53 930

原创 排序算法总结(一)

#includeusing namespace std;void Insert(int r[],int n){ for(int i=2;i<=n;i++){ if(r[i]<r[i-1]){ r[0]=r[i]; int j=i-1; for(;r[0]<r[j];j--){ r[j+1]=r[j]; } r[j+1]=r[0];//游标指向j

2015-03-12 10:52:27 573

原创 atoi函数编写

#include#includeusing namespace std;int ai(const char *p){ bool negflag = false; int rs = 0; if(*p=='+'||*p=='-'){ negflag=(*p=='-'); p++; } while(isdigit(*p)){ rs=rs*10+(*p-'0'); p++;

2015-03-11 21:05:41 925

转载 char *a 与char a[] 的区别

char *a = "hello" 中的a是指向第一个字符‘a'的一个指针char a[20] = "hello" 中数组名a也是执行数组第一个字符‘h’的指针但二者并不相同:看实例:把两个字符串相加:结果:对比:结果:把字符串加到指针所指的字串上去,出现段错误,本质原因:*d="0123456789"存放在常

2015-03-10 21:00:53 605

原创 leetcode_num118_Pascal's Triangle

Given numRows, generate the first numRows of Pascal's triangle.class Solution {public: vector > generate(int numRows) { vector> rs; if (numRows<=0){ return rs;

2015-03-10 20:58:56 793

原创 leetcode_num168&171_excel title&number

Given a positive integer, return its corresponding column title as appear in an Excel sheet.class Solution {public: string convertToTitle(int n) { string s; while(n){

2015-03-09 22:59:51 818

原创 leetcode_num169_Majority Element

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 majority element

2015-03-09 21:17:27 693

原创 leetcode_num190_Reverse Bits

Reverse bits of a given 32 bits unsigned integer.归并法class Solution {public: uint32_t reverseBits(uint32_t n) { n=(n>>16)|(n<<16); n=((n&0xff00ff00)>>8)|((n&0x00ff00ff)<<8);

2015-03-08 17:56:50 987

原创 leetcode_num112_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./** * Definition for binary tree * struct Tree

2015-03-08 17:04:09 797

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

2015-03-04 16:57:22 728

转载 中文词性标注解释一览表

Definitions of Chinese Part-of-Speech中文词性标注(33) [1]     AD    副词  Adverbs[2]     AS    语态词  --- 了[3]     BA    把[4]     CC    并列连接词(coordinating conj)[5]     CD    许多(many)

2014-11-01 11:54:19 2258

转载 自然语言处理(NLP)常用开源工具总结----不定期更新

学习自然语言这一段时间以来接触和听说了好多开源的自然语言处理工具,在这里做一下汇总方便自己以后学习,其中有自己使用过的也有了解不是很多的,对于不甚了解的工具以后学习熟悉了会做更新的。1.IKAnalyzerIK Analyzer是一个开源的,基于Java语言开发的轻量级的中文分词工具包。从2006.12推出1.0版本开始,IK Analyzer已经推出了多个版本,当

2014-11-01 11:14:46 2053

原创 Leetcode_num15_Maximun Subarray

题目:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray [4,−1,2,1]

2014-10-12 00:39:43 1045

原创 Leetcode_num14_Roman to Integer

题目:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.题目意思很简单,即将一个罗马数字的字符串,转化为整数。首先我们需要对罗马数字有一个基本的认识,由于题目已将数字大小限定在1~3999,所以我们只需考虑

2014-10-10 11:22:29 912

原创 Leetcode_num13_Climbing Stairs

题目:You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?很简单的思路,因为一次可以走1~2步,所以

2014-09-28 21:38:38 746

原创 Leetcode_num12_Search Insert Position

题目:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in t

2014-09-25 18:59:29 855

原创 Leetcode_num11_Remove Duplicates from Sorted List

题目:Given a sorted linked list, delete all duplicates such that each element appear only once.这道链表的题也比较简单,目标是为了去重,只是需要注意在去重的过程中需要使用while循环,使一个节点的下一个节点必须指向与其不同的节点上代码咯# Definition for singly-li

2014-09-25 17:15:09 859

原创 Leetcode_num10_Populating Next Right Pointers in Each Node

题目:Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL.Initially, all next pointers are set to NULL.You may

2014-09-24 20:10:05 786

原创 Leetcode_num9_Binary Tree Inorder Traversal

同num8一样,此题考查的是二叉树的中序遍历,即先左子树再节点再右子树、使用迭代法时,采用将节点和左子树均压入栈的方法,当左子树为NULL时,将top节点弹出,并存入结果列表,将next指针指向该节点的右节点代码如下:/** * Definition for binary tree * struct TreeNode { * int val; * Tre

2014-09-24 16:27:03 789

原创 Leetcode_num8_Binary Tree Preorder Traversal

题目:Given a binary tree, return the preorder traversal of its nodes' values.此题即为二叉树的前序遍历,递归的方法很简单:先节点再左子树再右子树;迭代的方法可以利用栈存储来完成遍历过程。补充递归与迭代的区别:许多问题是以递归的形式进行解释的,这只是因为它比非递归形式更为清晰。但是,这些问题的迭代往往比递归实现效率更

2014-09-24 09:46:24 903

空空如也

空空如也

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

TA关注的人

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