自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

二十三小时

Coding is not the whole story

  • 博客(152)
  • 资源 (22)
  • 收藏
  • 关注

原创 useful SQL in Presto

expand one, two or multiple arrays into rows (multiple columns)expand one arrayConvert one array to row. E.g. Convert the followingspeeds[1,2,3,4]tospeed1234with t...

2019-07-22 14:42:25 657 1

原创 Timezone in Python

Just as a markIf we want to set PST timezone for a given datetime, it should be usually UTC-8. But sometimes it could return UTC-7:53. How should we resolve? Use localize instead of replace timezone...

2018-12-07 21:33:29 367

原创 [Elasticsearch] setup Elasticsearch in intellij idea

IntroductionElasticsearch is quite a cool project. This post introduces how to setup Elasticsearch in IntelliJ Idea locally. After this, we are able to :read Elasticsearch source code within an IDEde

2018-01-19 19:55:24 2993

原创 debug date filter in logstash

BackgroundRecently some guys came by and were curious about the date filter in logstash (both 2.4 and 5.x, but I am using logstash 2.4 in this post). The basic function for date filter is to convert a

2017-07-15 02:52:53 845

原创 [Kibana > Timelion] Timelion.json is not working

Just a mark to investigate the reason configuration file of Timelion plugin is not working. It is maybe a designed feature. :) BackgroundIn Kibana 5.X, (specially Kibana 5.3.3 in my case), I have confi

2017-06-10 01:31:40 961

原创 Kibana displays customized percentage in pie chart

IntroductionKibana 3 has got a good pie chart, which will displays the percentage label by default. But when it comes to Kibana 4 or even Kibana 5.X, this feature has gone. Let’s see what it looks like

2017-05-05 19:14:40 1694

原创 Kibana Timelion Supports Percentiles

IntroductionTimelion has a good .es method which enables users to get certain metrics over the query results. The existing metrics include: count, avg, sum, min, max, cardinality. But I am eager to do

2017-04-11 01:11:10 2518

原创 Kibana aggregation with missing / null fields

BackgroundKibana is a good tool for aggregations. It looks like the group by in mysql. However Kibana will ignore documents without a given field when computing the aggregation. How can we take those d

2017-02-22 13:36:07 1320

原创 kibana uses openStreetMap and Gaode map with higher zoom level

Kibana mapBackgroundFrom July 11, 2016 Kibana was not allowed to use MapQuest anymore. But Kibana distributes their own map service named elastic tile map service. Unfortunately it limits the zoom leve

2017-02-12 12:30:02 1421

原创 [Kibana > Timelion] Divide multi-valued seriesList by another multi-valued seriesList

Kibana Timelion Plugin EnhancementWhy need to divide multiple valued seriesList?Timelion is quite a great plugin for computing two series in kibana. The divide computing supports divisor as a number or

2017-01-26 18:24:09 1761

原创 Vim 多行替换

Replace multiple lines in VimAim// to replace the following line with new multiple lines// original line "type": "string"// target lines "type": "string", "fie

2016-09-05 11:20:21 1709

原创 Java ObjectMapper String转HashMap

Just to remindHashMap<String, Object> rDefHashMap = om.readValue(rDefStr, new TypeReference<HashMap<String, Object>>() {});

2016-01-19 14:39:07 5721

原创 MongoDB Cluster Setting up [replSet + Sharding]

step 1 [on each server]sudo mkdir -p /data/mongodbwsdc/mongos/logsudo mkdir -p /data/mongodbwsdc/config/datasudo mkdir -p /data/mongodbwsdc/config/logsudo mkdir -p /data/mongodbwsdc/mongos/logsudo

2015-12-16 18:15:41 782

原创 SSH Login Shell

how to login into a remote host through ssh1, write a shell script (login.sh), like:#!/usr/bin/expect -fset user rootset host 10.10.2.176set password wsn++123set timeout -1spawn ssh $user@$hostexp

2015-12-08 10:44:56 1024

原创 python list 自定义排序

看到的一个知识点,稍加记录…数据格式a = [{'name':'jk', 'score':4, 'first':1, 'second':2, 'third':2}, {'name':'zz', 'score':1, 'first':0, 'second':0, 'third': 1}, {'name': 'ns', 'score':4, 'first':1, 'second':0, 'third':

2015-10-21 16:04:42 10377 1

原创 Advanced .vimrc config

1, using vundle to manage vim pluginsA detailed introduction from github: https://github.com/VundleVim/Vundle.vim2, the .vimrc configuration(PS I’d like to use macvim in mac os. A detailed introduction

2015-10-19 20:23:39 649

原创 对给定数组按奇偶性划分,不改变相对顺序

问题描述给定一个数组,比如 arr = { 1, 3, 1, 4, 1, 5, 2, 0},对该数组进行整理,使得所有奇数都在前面,所有的偶数都在后面,且保证所有奇数的相对顺序不改变,所有偶数的相对顺序不改变。问题解决Solution1:T(n) = O(n^2), S(n) = O(1)利用冒泡排序的思想,对数组进行整理即可。 思想:扫描数组,针对每个发现的奇数,都利用冒泡技术,往前移动该奇数,

2015-08-14 20:44:45 2122

原创 [微软苏州校招 Hihocoder] Disk Storage

#1100 : Disk Storage时间限制:10000ms单点时限:1000ms内存限制:256MB描述Little Hi and Little Ho have a disk storage. The storage's shape is a truncated cone of height H. R+H is radius o

2015-08-12 15:45:32 1724

原创 [poj] The Wedding Juicer | [lintcode] Trapping Rain Water II

问题描述给定一个二维矩阵,每个元素都有一个正整数值,表示高度。这样构成了一个二维的、有高度的物体。请问该矩阵可以盛放多少水?相关题目:POJ The Wedding JuicerDescriptionFarmer John’s cows have taken a side job designing interesting punch-bowl designs. The designs are cr

2015-08-09 11:34:37 1198

转载 bk树:编辑距离算法

算法出处:Matrix67大神,http://www.matrix67.com/blog/?s=bk%E6%A0%91背景 除了字符串匹配、查找回文串、查找重复子串等经典问题以外,日常生活中我们还会遇到其它一些怪异的字符串问题。比如,有时我们需要知道给定的两个字符串“有多像”,换句话说两个字符串的相似度是多少。 1965年,俄国科学家Vladimir Levenshtein给字符

2015-07-29 00:51:25 3603

原创 【c++】map 迭代器删除示例

C++ STL中的map是非常常见的。通常我们用如下方式来遍历,并且删除map中的一些entry:map<int, int> mp;mp.insert(make_pair(1,1));mp.insert(make_pair(2,3)); // insert some elementsfor (map<int, int>::iterator iter = mp.begin(); iter !=

2015-07-26 19:51:29 6998 1

原创 Best time to buy and sell stocks IV

题目https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/ Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum

2015-07-24 08:37:26 596

原创 Java Concurrent

Java ConcurrentExecutorServiceExecutorService exec = Executors.newCachedThreadPool(); // create a cached poolExecutorService exec = Executors.newFixedThreadPool(4); // fixed sized thread poolExecuto

2015-07-21 23:40:54 672

原创 lintcode: ugly number

问题描述Ugly number is a number that only have factors 3, 5 and 7.Design an algorithm to find the Kth ugly number. The first 5 ugly numbers are 3, 5, 7, 9, 15 …问题分析这个题,有多种方法求解,常见的是有辅助数据结构,比如priority_queue,

2015-07-05 23:42:31 2040

原创 数组进行多少次OP操作,才能有序

1 题目描述:有一个数组:2,1,4,3。对于数组,有一种操作op(idx):将该index对应的数字移到首位。比如:op(3):  2 1 4 3 -> 3 2 1 4op(1):  3 2 1 4 -> 2 3 1 4op(2):  2 3 1 4 -> 1 2 3 4 问对于给定的数组,数组各个元素是任意的整数,可能有重复值,需要多少次OP操作,才能使得数组有序?

2015-07-05 12:57:36 1349

原创 中序遍历二叉树+O(1)空间

问题描述中序遍历二叉树时,很简单,需要加上递归就可以优雅地实现了。当然,使用递归的话,函数调用栈的空间就会达到O(log n)。那么有什么方式,可以使得中序遍历二叉树的复杂度为O(1)呢?问题分析既然要保证O(1)复杂度,那么就不能使用递归调用了。目标方案应该是使用while或for循环的方式。下面借用一张图来解释(来源:http://www.2cto.com/kf/201402/277873.ht

2015-06-22 10:45:02 1729

原创 【算法】直方图中最大面积问题

问题描述给定一个直方图,求这个直方图中最大矩阵对应的面积是多少? 比如有个图如下 (对应的数组为:[2,1,5,6,2,3]) 那么对应的最大矩形的面积应该为 10: 问题分析这类题是很常见的一道题,也是面试当中很容易考到的一题。解决方法倒是挺多。常见的比如Divide-and-conqure等方法,复杂度也都是O(n log n)。 现在有没有一种更快的方法呢?复杂度可以达到 O(n)问题

2015-06-19 16:26:14 5435

原创 n*m 矩阵: set matrix zeroes

问题描述有个 N * M 的矩阵,其中有的元素是 0,如果是 0,那么将该行和该列都设置为0. 需要 O(1) 的空间复杂度问题分析初看此问题,确实很简单,没有过多算法内容。 如果有 O( M + N) 的空间,那么可以存储所有的含有 0 的列和行。然后再逐一设置 0 即可。 现在要求是使用 O(1) 的空间复杂度,该如何处理?问题求解扫描 (Row >= 1 && Column >= 1)

2015-06-11 17:01:10 860

原创 [概率]m个球扔到n个盒子

问题描述有m个球,要扔到n个盒子里。其中每个球都是互相独立地扔。问最后平均有几个盒子是有球的?问题解析这类问题是较为纯粹的数学问题,当然也可以用计算机精确地求出答案。方案一:编程解决p(m, i):表示前 m 个球,扔到 n 个盒子里,共占用了 i 个盒子的概率 于是 p(m, i) = p(m-1, i) * (i/n) + p(m-1, i-1) * (n-i+1)/n p(m, i) =

2015-06-07 08:25:16 4109

原创 [Lintcode] Maximum Gap Problem

问题描述在一个无序的数组中,如果对其进行排序,然后扫描一遍有序数组,可以获得相邻两元素的最大差值,比如 {-1, 2, 4, 9},那么最大差值就是4和9之间,是5. 现在如果不对原始数组进行排序,有什么好的方案,来获取有序形式下的最大差值? Given an unsorted array, find the maximum difference between the successive

2015-05-31 16:29:17 1568

原创 矩阵中求子矩形

问题描述有一个 n * n的矩形,其中每个元素只可能是0 or 1。比如如下矩阵A:1 1 0 00 0 1 11 0 1 01 1 0 1其中 A[0][0], A[0][1], A[3][0], A[3][1] 这四个元素恰好是一个长方形的四个角,且每个元素都是1. 因此称这四个元素围成了一个子矩形。现在需要判断,给定的矩阵A中,判断是否存在这样四个元素,都是1,且恰好围成一个子矩形?解决

2015-05-29 14:45:43 2145

原创 [Lintcode] Best Time to Buy and Sell Stock IV

问题描述Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most k transactions.Example Given price

2015-05-23 11:00:10 966

原创 C++ priority_queue 最大堆、最小堆

问题描述通常在刷题的时候,会遇到最大堆、最小堆的问题,这个时候如果自己去实现一个也是OK的,但是通常时间不太够,那么如何处理?这时,就可以借助C++ STL的priority_queue。具体分析需要注意的是,C++ STL默认的priority_queue是将优先级最大的放在队列最前面,也即是最大堆。那么如何实现最小堆呢?假设有如下一个struct:struct Node { int

2015-05-14 20:35:16 30993 1

原创 博弈游戏·Nim游戏·二

题目1 : 博弈游戏·Nim游戏·二时间限制:10000ms单点时限:1000ms内存限制:256MB描述Alice和Bob这一次准备玩一个关于硬币的游戏:N枚硬币排成一列,有的正面朝上,有的背面朝上,从左到右依次编号为1..N。现在两人轮流翻硬币,每次只能将一枚正面朝上的硬币翻过来,并且可以随自己的意愿,在一枚硬币翻转后决定要不要将

2015-05-11 12:50:51 1267

原创 M * N 矩阵的骨牌覆盖问题

问题描述有一个 M * N的矩阵,现在需要使用 1 * 2 的骨牌进行覆盖,问总的覆盖方案数有多少? 题目链接:http://hihocoder.com/contest/hiho43/problem/1问题求解标记骨牌覆盖状态 1, 横向排的骨牌表示: 1 1 2, 纵向排的骨牌表示: 0 1骨牌状态转移 对于第 i 行与第 i+1 行,其中某段格子状态如下:

2015-05-09 11:19:31 2444

原创 加油站问题

问题描述有一个环形轨道,上有若干加油站,一辆小车(初始时油箱为空,油箱容量无线)从某个加油站出发绕一圈,路上需要耗油,已知 加油站的总油量和路上需要消耗地油量一样多,问是否可以找到从一个加油站出发,小车可以正常绕一圈?问题解析其实上面的题与下面的题目类似:有一个循环数组,{1, 2, -3, 4, -5, -8, 9},问找出一个数,使得从该数出发,往右的所有子数组,比如 {2}, {2,-3},

2015-05-08 10:21:52 1039

原创 多处理机调度问题(NP)

问题描述有 n 个独立的任务,分配给 m 个相同的处理机进行处理,每个任务所花费的时间为 t[i], i = 1..n,每个任务独立,不可分割,不可中断。问题:这些处理机要处理完这些任务,所需要花费的最短时间是多少?问题解决该问题也是NP问题,也跟上篇博客中的装箱问题类似:http://blog.csdn.net/nisxiya/article/details/45533811 装箱问题,是给定容

2015-05-06 11:47:56 8894

原创 装箱问题(NP问题)

问题描述有n个物品,体积为 v[i],i = 1..n。 现在有若干同样的箱子,体积为C,C > v[i], i = 1..n。问最少需要多少箱子,才能装下所有的物品。问题求解这类问题是NP问题,即可以在多项式时间内验证一个解是否OK,但是不可以在多项式时间内求得该解。 装箱问题,有个近似解。First Fit (FF)首次适应解法。对于物品 i ,从当前装了物品的箱子中找到首个,其剩余容量可以放

2015-05-06 11:30:56 11049

原创 P, NP 问题

P问题:多项式时间可以解决的问题。NP问题: 多项式时间可以验证某种解法。但是是否可以多项式时间内解决某种问题,仍然得不到证明或证否。P属于NP问题,但是 P和NP 是否相等,仍然未解。NPC问题:一些比较难的NP问题,可以归约到NPC问题,即更为通用的一种解法,可以解决较多的NP问题。人们发现NPC问题,很难有多项式时间解法,因此人们逐渐相信NPC不可多项式解决,也就逐渐相信 P != NP。一些

2015-05-06 10:43:47 708

原创 2D矩阵求最大正方形子矩阵,各项元素为1

问题描述对于一个 m * n 的矩阵,每项元素为 0 或 1. 问题1求该矩阵中的最大子矩阵,子矩阵可以为长方形,但是子矩阵内的各项元素均为 1。解决1针对这个问题,可以枚举子矩阵的左右边界,复杂度为 O(n^2)。针对该边界内的m行,从上到下扫一次,每行的和,如果为左右边界之差,那么该行的每项元素都为 1 。从上往下扫各行,求得最长连续地满足要求的行数。从而可以求得子矩阵的面积。 求特定边界内每

2015-04-29 11:09:12 2088

hadoop 2.2.0 for eclipse plugin插件

hadoop 2.2.0 for eclipse plugin插件 可以直接使用 放入windows下Eclipse的plugin文件夹中即可

2014-11-02

hadoop eclipse plugin 源代码

hadoop eclipse plugin 源代码 需要自己编译

2014-11-02

C Interfaces And Implementations

C编程接口 C Interfaces And Implementations

2014-09-01

An Introduction to the Analysis of Algorithms

An Introduction to the Analysis of Algorithms_2nd Edition_Robert Sedgewick_2013 (2).pdf ) 算法分析

2014-09-01

Advanced Data Structures

高级数据结构 Advanced Data Structures

2014-09-01

Elements of Programming

Elements of Programming Addison-Wesley.

2014-09-01

Combinatorial Algorithms Second Edition

Combinatorial Algorithms Second Edition

2014-09-01

Analytic Combinatorics [Philippe Flajolet / Robert Sedgewick ]

Analytic Combinatorics [Philippe Flajolet / Robert Sedgewick ] Analytic combinatorics aims to enable precise quantitative predictions of the properties of large combinatorial structures. The theory has emerged over recent decades as essential both for the analysis of algorithms and for the study of scientific models in many disciplines, including probability theory, statistical physics, computational biology, and information theory. With a...

2014-09-01

算法艺术与信息学竞赛

算法艺术与信息学竞赛

2013-05-10

The art of unix programming, UNIX编程艺术

The art of unix programming UNIX编程艺术 英文版

2013-05-10

python api pdf

english version of python api document from original websites

2012-11-14

算法导论 第三版 英文版

算法导论 第三版 英文版

2012-09-24

操作系统习题集(第五版).pdf

操作系统习题集(第五版).pdf

2011-02-23

算法导论的课后习题答案

算法导论原书的习题答案,非常详细。是提高编程水平的必备书。

2010-05-22

算法导论IntroductionToAlgorithm

算法导论IntroductionToAlgorithm,原书电子版。各种编程的算法基础,必备版

2010-05-22

Java编程思想第四版(中文版)

这个是很有名的一本书。Java学习的必备书

2010-05-22

causes of love

this is about what causes the love (in English)

2010-05-22

数据结构c++ 专业版数据结构c++

专业版专业版专业版专业版专业版专业版专业版专业版专业版专业版专业版专业版专业版专业版专业版专业版专业版专业版专业版专业版专业版

2009-09-08

空空如也

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

TA关注的人

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