自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(17)
  • 资源 (4)
  • 收藏
  • 关注

原创 lintcode(103) Linked List Cycle II

Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.对于循环链表的判断,应该都很清楚,就是通过快慢指针,判断是否会追赶上,但是如果需要找出循环链表的起始节点,就需要先搞清楚快慢指针相遇时的路程差。假设链表起点为s,环的起始点为o,首次相...

2015-09-01 20:00:12 422

原创 Lintcode(198) Permutation Index II

查找存在重复元素中排列的序号这道题基于查找不存在重复元素中排列序号的基础之上,即P(n) = P(n-1)+C(n-1)C(n-1) = (首元素为小于当前元素,之后的全排列值)P(1) = 1;而不存在重复元素的全排列值C(n-1) = (n-1)!*k(k为首元素之后小于当前元素的个数)在存在重复元素的排列中首先全排列的值的求法变为:C(

2015-07-27 00:08:35 3289

原创 《算法心得》高效用法记录

值为1且最靠右的位元置为0 (如果存在): 0101 1110 => 010 1100 : x&(x-1)值为0且最靠右的位元置为1 (如果存在): 0101 1110 => 010 1111 : x|(x+1)将尾部的所有连续的1置为0(如果存在): 0101 0111 => 0101 0000 : x&(x+1)将尾部的所有连续的0置为1(如果存在): 0101 1000 =>

2015-07-05 14:57:26 570 2

原创 基于wait和notify的生产者消费者实例

package com.test;public class WaitNotify { private final int CAPACITY = 10; private volatile int size = 0; private final Object lock = new Object(); private final Object consumer = new Object()

2015-05-29 15:45:29 639

原创 Lintcode 389 Longest Increasing Continuous subsequence II

Give you an integer matrix (with row size n, column size m),find the longest increasing continuous subsequence in this matrix. (The definition of the longest increasing continuous subsequence here c

2015-05-26 15:48:02 962

原创 通过Callable,Future实现十亿数据的并行相加

在java线程中,Runables接口的run方法不提供返回值,因此无法用来进行并发执行但有一个ExecutorCompletionService可以异步提交submit(task(Callable)),ExecutorCompletionService对Callable生成FutureTask,FutureTask完成时会执行done操作,然后ExecutorComp

2015-05-25 16:21:20 794

原创 Lintcode 131 Building Outline

这道题确实挺纠结的,在Lintcode上过的也挺奇葩,有时候能过,有时候又过不了,但总体而言还是过了,写一下记录一下思路刚开始想的是用堆将大楼从高到低开始找轮廓,但是每次大楼分裂,或者从前面找到结果时,需要把vector里面的元素右移,复杂度太高,自然是过不了,只能过到第17组数据后来就改成了按坐标从左至右扫描大楼边的方式,并通过大堆记录当前楼的最高值,依次

2015-05-08 09:18:59 2857

原创 Lintcode 362 Sliding Window Maximum

Sliding Window MaximumGiven an array of n integer with duplicate number, and a moving window(size k), move the window at each iteration from the start of the array, find the maximum number inside

2015-05-03 13:34:55 976

原创 Lintcode 360 Sliding Window Median

Given an array of n integer, and a moving window(size k), move the window at each iteration from the start of the array, find the median of the element inside the window at each moving. (If there ar

2015-04-30 00:15:33 1789 2

原创 LintCode 364 Trapping Rain Water II

Given n * m non-negative integers representing an elevation map 2d where the area of each cell is 1 * 1, compute how much water it is able to trap after raining.给出 n * m 个非负整数,代表一张X轴上每个区

2015-04-29 00:16:30 2343

原创 c++二叉查找树,AVL树,红黑树,treap,splay树及笛卡尔树整理

在数据结构中,树的种类不计其数,百度百科上就有50多种,因此就把最近看的一些二叉查找树的特性和用途整理一下:二叉查找数的基本操作:插入insert,删除delete,查找search,遍历iterator,从某个节点开始的最大值minMum,某个节点开始的最小值maxMum为了保证查找的效率,人们提出让树尽量平衡的思想,也就是二叉平衡树,通过尽量控制

2015-04-27 23:52:34 1714

原创 红黑树的c++实现

通过阅读算法导论,基于红黑树的理解实现

2015-04-23 13:37:42 626

原创 LeetCode 174 Dungeon Game

经典的动态规划问题,每次保证血量不低于1,从结尾处开始从下往上遍历赋值。class Solution {public:       /**     * it is a typical DP problem     * in the problem of DungeonGame, the most important idea is that kn

2015-04-08 09:56:59 442

原创 LeetCode 23 Merge k Sorted Lists

这是一道基本的归并排序问题,设定步长d初始为1,然后以指数增长归并向量元素每次归并的思想就是将后一个链表的元素插入前一个链表,如果前一个链表为空,则前一个链表直接指向后一个链表当d大于等于n时结束归并,返回第一个向量元素即为所求#include #include using namespace std;struct ListNod

2015-04-08 09:49:49 518

原创 LeetCode 76 Minimum Window Substring

又是一年招聘季,是时候好好复习一下算法了,也开始将以前写过的一些算法题进行一下回顾,顺便开始学习写一下博客吧先把Leetcode上面的第76题,写一下这道题主要是求在一个字符串S中查找包含字符串T中所有元素的最小子串。For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BANC".

2015-04-01 21:49:05 558

原创 WebSocket 基于 Tomcat7.0.54 的server部署 与client访问

由于项目有保持实时连接请求数据的需要,通过查资料

2014-10-21 10:43:19 1034

原创 java 重载JTextField 使其具有背景图片和限制输入长度大小

<br />import javax.swing.*;<br />import java.awt.*;<br />import java.awt.event.*;<br />import java.awt.image.*;<br />public class MyTextField extends JTextField implements KeyListener{<br /> Tools to;<br /> TexturePaint texture;<br /> int maxlength;<br /> 

2011-04-21 20:31:00 1324 1

Java-WebSocket源码

Java-WebSocket 的源代码。

2014-10-21

java_websocket

websocket 的Java版本,有server和client,能够很好的发起websocket连接

2014-10-21

Jcrop截图插件源码

这是一个非常好的截图插件,实现了各种截图方法和截图参数的传递,稍作修改就能达到各种需求

2011-11-20

smartupload源码

让上传变得简单、明了,可以控制上传的大小、类型

2011-11-20

空空如也

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

TA关注的人

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