- 博客(144)
- 资源 (2)
- 收藏
- 关注
原创 聚茶吧的内容来源-Python爬虫
聚茶吧-汇聚茶的地方自己想着做一个以“茶”为主题的网站,从别的具有相同主题(茶叶)的站点上抓取文章,汇聚成一个站点,充实站点的内容, 靠内容取胜。名字就叫聚茶吧(域名是jucha8.com, 取"聚茶吧"的谐音)。准备使用爬虫抓取100万左右的文章,充实茶叶相关的内容,尽可能的引流吧……python爬虫的实现那么,聚茶吧爬虫代码是如何实现的呢?假设要抓取的站点是A,则:impo
2017-02-14 21:57:36
643
原创 内容站入门-聚茶吧
注意到推酷之后,自己也想着做个类似的主题网站,从别的具有相同主题的站点上抓取文章,汇聚成一个站点,充实站点的内容, 考内容取胜。想来想去,准备做一个以“茶叶”为核心主题的内容站, 名字就叫聚茶吧(域名是jucha8.com, 取"聚茶吧"的谐音)。准备使用爬虫抓取100万左右的文章,充实茶叶相关的内容,尽可能的引流吧…… SEO的路已经开始,慢慢摸索吧
2017-02-13 21:31:33
787
原创 使用Servlet获取用户日志
前段时间,实验室需要开发一个用户日志模块,来对实验室的Web项目监控,获取用户的行为日志。个人首先觉得应该主要使用js来实现相关功能,无奈js水平着实太低,最终采用了servlet的方式来实现。项目介绍自己先从github上查询到了一个相关项目,clickstream,我先来介绍一下该项目是怎么实现的。 Clickstream的实现它首先使用了一个Listener来监听ServletContext
2015-10-15 08:50:05
1755
原创 #1014 : Trie树
时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi和小Ho是一对好朋友,出生在信息化社会的他们对编程产生了莫大的兴趣,他们约定好互相帮助,在编程的学习道路上一同前进。这一天,他们遇到了一本词典,于是小Hi就向小Ho提出了那个经典的问题:“小Ho,你能不能对于每一个我给出的字符串,都在这个词典里面找到以这个字符串开头的所有单词呢?”身经百战的小Ho答道:“怎么
2015-09-28 19:07:05
633
原创 mysql表去除重复的记录
要求: 表a有两个字段id,name。id是主键,子增长;name有重复。除去多余的重复记录。如name有4个重复的值,删除3个,保留一个即可。delete from a where a.id in( select * from ( select distinct t.id from a, a as t where a.name=t
2015-09-06 08:47:13
710
原创 AOP的XML配置:配置了两个BeanNameAutoProxyCreator,会怎么样?
在配置Spring AOP时,可以使用org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator来完成目标服务的拦截。 比如:<bean id="serviceInteceptorProxyCreator" class="org.springframework.aop.framework.autoprox
2015-08-28 09:54:02
4070
原创 记录下log4j的两种配置方式
XML文件配置<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"><log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'> <!-- 输出到控制台 --> <appender nam
2015-08-24 13:16:37
1305
原创 Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array.For example, Given nums = [0, 1, 3] return 2.Note: Your algorithm should run in line
2015-08-24 10:10:06
655
原创 Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with cons
2015-08-02 20:21:05
665
原创 Lowest Common Ancestor of a Binary Search Tree
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two
2015-07-11 21:27:37
889
原创 Palindrome Linked List
Given a singly linked list, determine if it is a palindrome.Follow up: Could you do it in O(n) time and O(1) space?思路: 把链表一分为二,把右边的一半翻转,再逐个比对左右的链表即可。/** * Definition for singly-linked list. * struc
2015-07-10 22:34:29
1451
原创 leetcode--Kth Smallest Element in a BST
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST’s total elements.Follow up: What if the BST is mod
2015-07-02 21:20:51
4301
原创 流水号的生成(日期+业务码+自增序列)
项目开发时,使用了两套数据库,开发环境和上线环境,数据库表中大多采用了自增主键, 比如:id int unsigned primary key auto_increment,但往往会碰到一些问题,比如: 开发环境中,使用爬虫抓取一些数据,建立索引,再把数据迁移到上线环境,会导致索引中的id和 上线环境数据库中id对不上,所以决定使用字符串作为主键。那么问题来了,如何生成唯一的序列号? 格式按
2015-06-29 12:01:47
36424
1
原创 项目自动化发布与部署
目前,部署的方式是:一个项目一台机器,使用3个tomcat部署的方式。以往,是本地(windows)开发、打包然后上传的Linux服务器上,不太方便,所以,使用SVN+Shell的方式自动化部署项目。主要思路:在Linux服务器上通过svn clone一份源码。当要新发布工程时,将本地的源码更新到svn,服务器上的源码也执行更新操作即可。先说明项目的部署文件夹:/xxx/tomcats/工程名。该文
2015-06-22 11:08:24
1301
原创 Rectangle Area
Find the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.Rectangle Area Assume that the t
2015-06-08 21:16:18
997
原创 Count Complete Tree Nodes
Given a complete binary tree, count the number of nodes.Definition of a complete binary tree from Wikipedia: In a complete binary tree every level, except possibly the last, is completely filled, and
2015-06-06 13:36:27
1168
原创 House Robber II
Note: This is an extension of House Robber.After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This time, all
2015-05-30 20:20:13
703
原创 最后一个被删除的元素
n个元素围成一圈,每次删除第m个元素,求最后一个被删除的元素。#include <iostream.h>#include "list"using namespace std;//使用list而非vector int findLast(int m,int n){ if(m<=0||n<=0){ return -1; } list<int> v;
2015-05-30 15:38:05
820
原创 Kth Largest Element in an Array
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example,Given [3,2,1,5,6,4] and k = 2, return 5.
2015-05-23 18:16:33
1141
原创 Add and Search Word - Data structure design
Design a data structure that supports the following two operations:void addWord(word) bool search(word) search(word) can search a literal word or a regular expression string containing only letters a
2015-05-16 19:46:44
1224
原创 Implement Trie (Prefix Tree)
Implement a trie with insert, search, and startsWith methods.Note: You may assume that all inputs are consist of lowercase letters a-z.思路: 之前也没有接触过Trie,百科上查了一下,大概就是词源的问题,N个word有公共前缀,只是后缀不同,可以用树表示。 可
2015-05-08 21:32:21
1046
原创 Count and Say
The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, …1 is read off as “one 1” or 11. 11 is read off as “two 1s” or 21. 21 is read off as “one 2, the
2015-05-07 20:28:37
977
原创 Fraction to Recurring Decimal
Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeating, enclose the repeating part in parentheses.For exam
2015-05-07 19:22:13
731
原创 OSCache源码阅读(二)
前文LRU Cache 暨LinkedHashMap源码阅读提到了如何使用LinkedHashMap来实现一个LRU数据结构,今天在看OSCache代码算法部分的时候,就用到了该知识,what was done contributes what is done now。algorithm包是包含下列缓存过期策略的类: 下面重点介绍LRU和FIFO。LRUprivate Collection l
2015-05-07 11:51:17
1056
原创 LRU Cache 暨LinkedHashMap源码阅读
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if
2015-05-06 19:23:36
897
原创 OSCache源码阅读(一)
自己在开发JavaEE的项目时,采用了基于Spring MVC + MyBatis +Sitemesh +AngularJS + semantic-ui的组合,使用maven作为项目管理、SVN作为代码版本控制工具。前台通过ajax从后台获取数据,再在前台进行DOM渲染,于是,数据加载的时候,页面会有一定程度的"空白"现象。为了解决这个问题,最好的办法的是把动态页面静态化,页面只进行一次渲
2015-05-05 21:24:43
1340
原创 Reverse Linked List
Reverse a singly linked list.click to show more hints.Hint:A linked list can be reversed either iteratively or recursively. Could you implement both?思路: 迭代的方式,可以使用一个哨兵节点,方便反转;
2015-05-05 18:52:50
773
原创 Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1->1-
2015-05-04 21:38:50
748
原创 Isomorphic Strings
Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with anot
2015-04-30 21:37:42
871
原创 编程之美3.2 电话号码对应英语单词
java实现:import java.util.ArrayList;import java.util.List;public class Telphone { /** * 保存每个数字对应的字母序列 */ static String[] c = new String[] { "", // 0 "", // 1 "abc", // 2 "def", /
2015-04-26 18:34:30
804
原创 求从1到参数n中的各个数字中,各个位上1出现的次数和
/** * 求从1到参数n中的各个数字中,1出现的次数和 * * @param n * @return */ public static int countOne(int n) { int factor = 1; int cur; int low; int high; int cnt = 0; while ((n / factor) != 0) {
2015-04-26 10:28:46
740
原创 翻转字符串中单词的顺序
问题:翻转字符串中的单词顺序,如“hello world”变成“world hello”。要求使用常量空间。c++代码如下:void reverse(string &s, int start, int end){ int len=end+start; int center=len/2; for(int i=start;i<center;i++){
2015-04-25 21:02:00
985
原创 Number of Islands
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assu
2015-04-09 18:50:50
808
原创 Dungeon Game
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially p
2015-04-07 20:00:19
555
原创 Binary Tree Right Side View
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example:Given the following binary tree, 1
2015-04-04 08:57:39
1084
原创 摩根斯坦利面试——Java多线程
今天上午,参加大摩的面试,自觉失败,记录一下过程。面试官看着简历,并没有就简历提问,整个过程都在问java多线程的问题。1. ReentrantLock,作为可重入锁,怎么理解“可重入”二字,有没有不可重复的锁?我:获得对象锁的线程能够再次获得对象锁,访问对象……被鄙视了,后来想想,应该把递归这种场景说下;2.生产者-消费者模型怎么实现?我:使用synchronized或者Lo
2015-04-03 17:03:23
3127
原创 House Robber
House Robber Total Accepted: 212 Total Submissions: 780My SubmissionsQuestion Solution You are a professional robber planning to rob houses along a street. Each house has a certa
2015-03-31 20:07:07
1433
原创 最近点对(Java实现)
最近点对问题:在二维平面上的n个点中,快速的最近的一对点的距离。java实现:package p2;import static java.lang.Math.*;import java.util.ArrayList;import java.util.Arrays;import java.util.Collections;import java.util.Compara
2015-03-27 22:02:36
6080
2
原创 斐波那契数列的矩阵解法(java实现)
使用了二分法import java.util.Scanner;/** * 求斐波那契数列 * * [F(n+1) F(n)] [1 1 ]^n (n次方,可以使用归纳法证明) * | | =| | * [F(n) F(n-1)] [1 0 ]
2015-03-27 16:36:14
3618
原创 二进制中1的个数以及时间比较
public class Algorithm { public static void main(String[] args) { long t1 = System.currentTimeMillis(); for (int i = -10000000; i < 10000000; i++) { countOne(i); } long t2 = System.curren
2015-03-18 21:29:50
1209
jQueryFileUploadMaster 插件 spring mvc简单整合
2013-08-16
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人