- 博客(18)
- 资源 (11)
- 收藏
- 关注
原创 关于某日访问次数最多的IP的topK问题的三种解法
题目描述在july大神的博客中,看到这样两道题:1. 海量日志数据,提取出某日访问百度次数最多的那个IP。2. 假设目前有一千万个记录(这些查询串的重复度比较高,虽然总数是1千万,但如果除去重复后,不超过3百万个。一个查询串的重复度越高,说明查询它的用户越多,也就是越热门。),请你统计最热门的10个查询串,要求使用的内存不能超过1G。现在我将两题结合一下:假如有1千万+的...
2018-08-19 20:32:01 7558 1
原创 TF-IDF 原理及sklearn中的tf-idf实例分析
背景介绍在一个大的文本语料库中,一些单词将出现很多次(例如 “the”, “a”, “is” 是英文),因此对文档的实际内容没有什么有意义的信息。 如果我们将直接计数数据直接提供给分类器,那么这些频繁词组会掩盖住那些我们关注但很少出现的词。 为了为了重新计算特征权重,并将其转化为适合分类器使用的浮点值,因此使用 tf-idf 变换是非常常见的。 Tf表示术语频率,而 tf-idf 表示术语...
2018-08-18 22:32:20 12251 3
原创 矩阵快速幂的问题
前言这个问题,本科ACM时期做过专门的总结,但是,由于后来也没有使用过相关的知识,就忘得差不多了最近回顾了一下之前的博客链接快速幂取模算法 快速幂算法模板 矩阵乘法快速幂模板 相关的地址矩阵快速幂的写法 while(N) { if(N&1) res=res*A; n>>=...
2018-08-31 00:20:38 5342
原创 快速排序的递归和非递归实现 c语言版本
#include <iostream>void quick_sort(int s[], int l, int r){ if (l < r) { int i = l, j = r, pivot = s[l]; while (i < j) { whil
2018-08-30 17:48:43 10685 2
原创 利用cre2进行分组模式匹配的实例
code#include <stdio.h>#include <stdlib.h>#include <string.h>#include <cre2.h>int init_ptn(const char *str_ptn, cre2_regexp_t **pPtn){ // 初始化cre2的正则表达式 cre2_opt...
2018-08-28 09:04:26 5550
原创 python 通过队列实现栈
前言原理比较简单,不再赘述codeimport collectionsclass MyStack: def __init__(self): """ Initialize your data structure here. """ self.queue = collections.deque() d...
2018-08-26 17:52:24 5422
原创 python实现二叉树的重建2 之由中序遍历和后序遍历重建
前言通过上一节对python实现二叉树的重建1 之由前序遍历和中序遍历重建,我相信我们再来做这个问题就不难了,完全可以照猫画虎的来实现,具体的原理几乎是一样的,直接上代码了code# 通用解法 def buildTree(self, inorder, postorder): """ :type inorder: List[int] :...
2018-08-26 15:27:51 5826
原创 python实现二叉树的重建1 之由前序遍历和中序遍历重建
前言此题是关于树的面试题目的常见题型,题目的含义很清晰,这个就不用多说了解法关于这道题的解法有很多不同的样式,通用的解法是这样的: 假如现在我们有如下两个遍历的情况preorder: [1, 2, 4, 5, 3, 6]inorder: [4, 2, 5, 1, 6, 3]那么我们建树的办法通常是1.用先序遍历的第一个元素也就是1,作为root2.然后在ino...
2018-08-26 14:54:35 6031 2
原创 由动态规划计算编辑距离引发的思考
简单介绍编辑距离算法: https://www.cnblogs.com/BlackStorm/p/5400809.html https://wizardforcel.gitbooks.io/the-art-of-programming-by-july/content/05.02.html https://www.dreamxu.com/books/dsa/dp/edit-distance...
2018-08-24 21:21:23 5360
原创 使用python建立简单的树机构
代码import sysclass TreeNode: def __init__(self, x): self.val = x self.left = None self.right = Noneclass Solution: def preorderTraversal(self, root): &amp;quot;...
2018-08-21 17:54:49 5853
原创 2019秋招面试常考题目
自然语言处理tf-idf的公式编辑距离的代码和思想新词发现的公司和原理大数据相关十道海量数据处理面试题叙述hadoop中的map-reduce过程,以及shuffle过程杂题2^32=4G...
2018-08-19 21:51:23 5956
原创 c语言使用指定字符串替换特定的子串
前言当前程序是在linux环境下执行的代码#include<stdio.h>#include<stdlib.h>#include<string.h>#define MAX_UTF8_RES_LEN 1024int replace_all(char* str, size_t strLen, const char* d, const char...
2018-08-14 16:12:50 12863 2
原创 c语言从stdin读入
代码#include<stdio.h>#include<stdlib.h>intmain(int argc, char* argv[]){ char * line = NULL; size_t len = 0; ssize_t read_len; while ((read_len=getline(&line, &...
2018-08-09 11:22:59 9284
原创 python 实现桶排序
前言桶排序(Bucket sort)或所谓的箱排序,是一个排序算法,工作的原理是将数组分到有限数量的桶里。每个桶再个别排序(有可能再使用别的排序算法或是以递归方式继续使用桶排序进行排序)。桶排序是鸽巢排序的一种归纳结果。当要被排序的数组内的数值是均匀分配的时候,桶排序使用线性时间( Θ ( n ) {\displaystyle \Theta (n)} {\displaystyle \Theta...
2018-08-09 09:35:36 10232
原创 docker 常用命令集合
查看imagesdocker images查看containerdocker psdocker container ps -a启动containerdocker container start #####暂停containerdocker container stop #####删除containerdocker conta...
2018-08-04 18:20:04 5276
原创 linux 下根据cpp文件快速书写头文件
假设我们现在有一个hello.cc文件,我们如果想要书写它的头文件hello.h,使用如下的命令即可:cat hello.cc | grep "^\w.*)$" > hello.h然后我们在hello.h中添加我们依赖的头文件即可...
2018-08-02 20:12:51 5410
item_seleted
2019-01-22
python画小猪佩奇
2019-01-20
Box2D_v2.1.2已经编译好的文件
2018-11-07
Box2D_v2.1.2
2018-11-07
2018 Google kickstart Problem A. Planet Distance 输入数据
2018-05-27
笨方法学python3 Learn Python 3 the Hard Way
2018-04-06
用python进行数据分析 第二版 Python for Data Analysis, 2nd Edition
2018-04-06
SQL与关系数据库理论:如何编写健壮的SQL代码 第二版
2018-02-26
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人