自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

给永远比拿愉快

操蛋的人生操蛋地过

  • 博客(43)
  • 资源 (19)
  • 收藏
  • 关注

原创 动态获取Bing每日壁纸

我们可以通过访问:http://cn.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=1获得一个XML文件,里面包含了图片的地址。上面访问参数的含义分别是: 1、format,非必要。返回结果的格式,不存在或者等于xml时,输出为xml格式,等于js时,输出json格式。2、idx,非必要。不存在或者等于0时,输出当天的图片,-1为已经预备用于明天显

2015-04-28 21:53:23 8124 2

原创 Java8 Lambda表达式入门

Lambda表达式的实质就是一个匿名函数。C#3.0引入了Lambda表达式,Java8也不甘示弱。Java8发布很久了,今天安装了JDK体验了Java8中的Lambda表达式。首先看一个不适用Lambda表达式的例子。 比如我们要对一组字符串进行排序。public class Hello { public static void main(String[] args) {

2015-04-23 22:52:08 1509

原创 建造者模式

定义:将一个复杂对象的构造与它的表示分离,使同样的构建过程可以创建不同的表示,这样的设计模式被称为建造者模式。 (separate the construction of a complex object from its representation so that the same construction process can create different representation

2015-04-22 23:54:58 1200 1

原创 单例模式

单例模式(Singleton Pattern)是 Java 中最简单的设计模式之一,属于创建型模式。 单例模式定义:保证一个类仅有一个实例,并提供一个访问它的全局访问点。单例模式的使用场景: 比如要求产生唯一序列号; 比如创建的对象需要消耗的资源过多,如 I/O 与数据库的连接等。 单例模式的特点:①构造函数是私有的;②单例类只能有一个实例。其实②是①的结果。通常可以使用下面的几种方式创建单例模式

2015-04-21 23:28:32 980

转载 23种设计模式全解析

一、设计模式的分类总体来说设计模式分为三大类:创建型模式,共五种:工厂方法模式、抽象工厂模式、单例模式、建造者模式、原型模式。结构型模式,共七种:适配器模式、装饰器模式、代理模式、外观模式、桥接模式、组合模式、享元模式。行为型模式,共十一种:策略模式、模板方法模式、观察者模式、迭代子模式、责任链模式、命令模式、备忘录模式、状态模式、访问者模式、中介者模式、解释器模式

2015-04-21 22:29:31 835

原创 Leetcode: Reverse Bits

题目: Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 001110010

2015-04-21 10:55:40 1674 2

原创 Leetcode: Subsets

题目: Given a set of distinct integers, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.For example, If S

2015-04-20 23:33:19 1170

原创 Leetcode: House Robber

题目: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent h

2015-04-20 18:18:22 1401

原创 Leetcode: Set Matrix Zeroes

题目: Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. 提示: Did you use extra space? A straight forward solution using O(mn) space is probably a bad idea.

2015-04-19 22:20:06 1229

原创 Leetcode: Permutations II

题目: Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [2,1,1]. 这

2015-04-19 19:26:46 1084

原创 Leetcode: Permutations

题目: Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1]. 思路分析: 思路一: 最容易想到

2015-04-18 20:43:15 1358

原创 Leetcode: Container With Most Water

题目: Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find tw

2015-04-16 20:12:30 951

原创 Java Swing程序开发—右下角显示进度条

虽然自己不喜欢Java的GUI程序,但是工作原因,听从上级安排。转入正题:这篇文章实现在桌面右下角显示一个进度条,显示当前程序运行的进度。而且鼠标能够拖动进度条。有需要的童鞋,可以直接拷贝代码过去使用!Java参考代码:import java.awt.Dimension;import java.awt.Insets;import java.awt.Toolkit;import j

2015-04-15 19:56:30 4207 1

原创 C#中的多维数组和交错数组

C#中有多维数组和交错数组,两者有什么区别呢! 直白些,多维数组每一行都是固定的,交错数组的每一行可以有不同的大小。 以二维的举例,二维数组就是m×n的矩阵,m行n列;而交错数组(又叫锯齿数组)有m行,但是每一行不一定是n列。Got it? 还有要注意C#中的数组也是一种类型(C++中不是)! 下面看实例: 二维数组:public static void Main(){ int r

2015-04-14 21:12:10 7746 2

原创 Leetcode: Minimum Path Sum

题目: Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at

2015-04-14 20:38:45 924

原创 C++中动态申请数组

动态申请一维数组 申请使用new,释放使用delete[] 可以通过数组名[下标]和*(数组名+下标)的方式访问数组int main(){ int number = 10; int *array = new int[number]; //数组初始化 for (int i = 0; i < number; ++i) { array[i] =

2015-04-14 19:49:33 10689

原创 Leetcode: Generate Parentheses

题目: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:“((()))”, “(()())”, “(())()”, “()(())”, “()()()”

2015-04-13 20:36:55 956

原创 Leetcode: Swap Nodes in Pairs

题目: Given a linked list, swap every two adjacent nodes and return its head.For example, Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. You

2015-04-12 18:48:37 912

原创 Leetcode: Rotate Image

题目: You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up: Could you do this in-place?思路分析: 最笨的方法,重新开辟一个矩阵空间,做旋转。(题目要求最好能就地旋转) 更好的方法:先将矩阵上下对折,然

2015-04-12 15:49:47 905

原创 Leetcode: Gray Code

题目: The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence of

2015-04-11 15:26:23 1223

原创 Leetcode: Search a 2D Matrix

题目: Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer of

2015-04-10 23:48:59 826

原创 Leetcode: 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-10 11:05:29 808

原创 Leetcode: Unique Paths

题目:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to rea

2015-04-10 01:01:54 1075

原创 观察者模式

《Head First Design Pattern》一书中对观察者模式的定义如下: The Observer Pattern defines a one-to-many dependency objects so that when one object changes state, all of its dependents are notified and updated automatic

2015-04-09 22:02:45 1213 3

原创 Leetcode: Convert Sorted Array to Binary Search Tree

题目: Given an array where elements are sorted in ascending order, convert it to a height balanced BST.分析: 将已经排序好的数组转成高度平衡的二叉排序树。 依旧二分法。C++参考代码:/** * Definition for binary tree * struct TreeNode {

2015-04-09 11:48:34 944

原创 Leetcode: 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 the array.

2015-04-08 21:05:01 760

原创 Leetcode: Sum Root to Leaf Numbers

题目:Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number123.Find the

2015-04-07 19:09:54 1451

原创 Leetcode: Word Break

题目: Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, given s = “leetcode”, dict = [“leet

2015-04-06 21:26:00 709

原创 Leetcode: Binary Tree Right Side View

题目:Given a binary tree, imagine yourself standing on theright side of it, return the values of the nodes you can see ordered from top to bottom.For example:Given the following binary tree,

2015-04-06 15:20:49 1326

原创 Leetcode: Best Time to Buy and Sell Stock II

题目: 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 as many transactions as you like (ie, buy on

2015-04-05 22:55:07 943

原创 Leetcode: Best Time to Buy and Sell Stock

题目: Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),

2015-04-05 22:40:49 778

原创 Leetcode: Linked List Cycle II

题目: Given a linked list, return the node where the cycle begins. If there is no cycle, return null. 思路分析: 和《Leetcode: Linked List Cycle 》一样还是双指针的方法。一个循环链表如图 slow指针走了S=X+Y fast指针走了F=X+Y+Z+Y 两个指针相遇。

2015-04-05 12:11:16 849

原创 Leetcode: Linked List Cycle

题目: Given a linked list, determine if it has a cycle in it. 思路分析: 利用快慢指针slow,fast。 slow指针每次走一步,fast指针每次走两步,倘若存在环,则slow和fast必定在某一时刻相遇。C++参考代码:/** * Definition for singly-linked list. * struct ListNo

2015-04-05 11:01:59 960

原创 Leetcode: Populating Next Right Pointers in Each Node

题目: Given a binary treestruct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next;}Populate each next pointer to point to its next right node. If there is no next right

2015-04-04 23:55:44 932

原创 Leetcode: Insertion Sort List

题目:Sort a linked list using insertion sort. 即使用插入排序对链表进行排序。思路分析: 插入排序思想见《排序(一):直接插入排序 》C++参考代码:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; *

2015-04-04 21:32:40 777

原创 Leetcode: Construct Binary Tree from Inorder and Postorder Traversal

题目: Given inorder and postorder traversal of a tree, construct the binary tree.Note: You may assume that duplicates do not exist in the tree. 根据二叉树的中序遍历和后续遍历结果构造二叉树。思路分析: 这道题和上道题《 Leetcode: Constr

2015-04-03 22:33:11 914

原创 Leetcode: Construct Binary Tree from Preorder and Inorder Traversal

题目: Given preorder and inorder traversal of a tree, construct the binary tree.Note: You may assume that duplicates do not exist in the tree. 根据前序遍历和中序遍历结果构造二叉树。思路分析: 分析二叉树前序遍历和中序遍历的结果我们发现: 二叉树中序遍

2015-04-03 21:54:27 1100

原创 Leetcode: Binary Tree Postorder Traversal(二叉树后序遍历)

题目: Given a binary tree, return the postorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1].Note: Recursive solution is trivial,

2015-04-02 21:53:20 1023

原创 Leetcode: Binary Tree Inorder Traversal(二叉树中序遍历)

题目: Given a binary tree, return the inorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,3,2].Note: Recursive solution is trivial, c

2015-04-02 20:43:06 988

原创 Java中日期API常见问题整理

今天在使用Java日期API的时候遇到的一些问题,自己整理了下。貌似JDK8中有关于时间行的API,可是JDK8用的还不是很多,先弄明白7的相关知识。 问题1:如何以制定格式显示时间? 问题2:如何计算时间间隔? 问题3:如何计算指定时间间隔以后的时间?下面直接上代码(使用JUnit4进行测试):import java.text.DateFormat;import java.text.Sim

2015-04-02 14:53:40 1123

Android编程权威指南

国外计算机书籍翻译版本!课程从基础知识讲起,各章节内容以循序渐进的方式编排,本书旨在让你跨越学习的初始障碍,能够充分利用其他各种参考资料和代码实例类图书来深入学习。

2015-03-07

windowbuilder-indigo

开发Java桌面程序的Eclipse插件,以可视化的形式进行控件的拖拽!

2015-02-02

exe4j_windows-x64_4_5_2

帮你轻松完成Java程序打包成exe程序,附带注册码!

2015-02-02

Struts_Hibernate_Spring集成开发宝典

Struts_Hibernate_Spring集成开发宝典,实例讲解很详细!JavaWeb开发值得参考!

2015-02-02

VC++_2010入门经典

《VC++_2010入门经典》完全版,完全解析VC++2010,学习VC++的经典图书!

2015-02-02

JQuery UI API

JQuery开发的API帮助文档,提供详细的函数说明和用法!

2014-03-09

JQuery API CHM

JQuery开发的API帮助文档,里面有各种函数的详细用法!

2014-03-09

JavaScript使用范例宝典

JavaScript使用帮助文档,里面提供了很多示例参考

2014-03-09

Java+EE+6+API+Specifications_中文版

Java Web开发API手册 Servlet JSP官方API

2013-12-05

Expression_Blend实例中文教程

开发Silverlight程序,Expression Blend作为开发的利器,入门的好资料……

2013-03-14

Java基础知识

最新的java开发基础知识 从入门开始到精通

2012-09-28

空空如也

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

TA关注的人

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