自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(45)
  • 收藏
  • 关注

原创 关于可重入锁、可中断锁和公平锁的理解

1.可重入锁如果锁具备可重入性,则称作为可重入锁。像synchronized和ReentrantLock都是可重入锁,可重入性在我看来实际上表明了锁的分配机制:基于线程的分配,而不是基于方法调用的分配。举个简单的例子,当一个线程执行到某个synchronized方法时,比如说method1,而在method1中会调用另外一个synchronized方法method2

2017-10-31 21:28:34 880

原创 SpringBatch批处理框架学习笔记(一)

由于在某厂实习的时候主要做的是后台批处理模块的工作,因此接触到了SpringBatch这个批量处理工具,Spring及其子项目实在是太强大了,无所不能。由于批量处理这个工作并不是属于大部分项目会使用到的,因此市面上的书籍并不是特别多。这里推荐一个我认为还不错的入门书籍:《SpringBatch 批处理框架》刘相编著在信息系统中,联机和批处理是计算机处理的两种基本模式,前者需要快

2017-08-06 17:25:08 731

原创 Git 常用操作介绍

安装方法就不赘述了,安装完成后,还需要最后一步设置,在命令行输入:$ git config --global user.name "Your Name"$ git config --global user.email "[email protected]"注意git config命令的--global参数,用了这个参数,表示你这台机器上所有的Git仓库都会使用这个配置,当然也可以对某个

2017-07-29 10:54:12 373

原创 【算法课程作业说明】

【注】由于本账号也会同时写其他类型的博客,特此备注:1、每周leetcode博客系列见类别“leetcode”系列。2、课后练习证明题见title为“【作业】算法概论课后证明题8.14”的博客。

2017-06-30 22:41:25 296

原创 【作业】算法概论课后证明题8.14

【算法分析课程作业】教材:《算法概论》Sanjoy Dasgupta Christos Papadimitriou Umesh Vazirani著题号:8.14题目描述: 证明如下问题是NP-完全的:给定一个无向图G=(V, E)和整数k,求G中一个规模为k的团以及一个规模为k的独立集。假定他们都是存在。

2017-06-30 13:27:24 956

原创 LeetCode:Best Time to Buy and Sell Stock

描述 Say you have an array for which the i-th 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 t

2017-06-28 14:15:46 221

原创 Redis缓存技术介绍

概念redis是一个key-value存储系统。和Memcached类似,它支持存储的value类型相对更多,包括string(字符串)、list(链表)、set(集合)和zset(有序集合)。这些数据类型都支持push/pop、add/remove及取交集并集和差集及更丰富的操作,而且这些操作都是原子性的。在此基础上,redis支持各种不同方式的排序。

2017-06-27 19:27:00 1593

原创 计算机网络中TCP、IP协议的对比

在OSI模型中,运输层的作用是向它的上层提供通信服务,它是面向通信部分的最高层,同时也是用户功能中的最底层。运输层为应用进程之间提供端到端的逻辑通信,而网络层是以主机为个体的概念。运输层还需要对收到的报文进行差错检测。运输层有两种不同的运输协议:用户数据报协议UDP(User Datagram Protocol)

2017-06-27 14:40:25 628

原创 浅析Java设计模式中的单例模式

单例模式Java中的设计模式总结来说至少有23种,而单例模式是其中最简单且最常用的设计模式之一。

2017-06-27 10:14:49 336

转载 常见消息队列中间件RabbitMQ介绍

引言你是否遇到过两个(多个)系统间需要通过定时任务来同步某些数据?你是否在为异构系统的不同进程间相互调用、通讯的问题而苦恼、挣扎?如果是,那么恭喜你,消息服务让你可以很轻松地解决这些问题。消息服务擅长于解决多系统、异构系统间的数据交换(消息通知/通讯)问题,你也可以把它用于系统间服务的相互调用(RPC)。本文将要介绍的RabbitMQ就是当前最主流的消息中间件之一。RabbitMQ

2017-06-27 08:52:32 372

原创 浅析Hadoop中MapReduce任务执行流程

MapReduce任务的执行流程非常复杂,但是可以用一个比较粗糙的流程图来描述,描述了一个MapReduce任务从提交到分发和执行完毕的完整过程:这里要提一下YARN框架,它主要负责的是资源的调度,YARN集群包含两种节点,一种是ResourceManager,这个主要负责资源的管理和调度,一种是NodeManager,这个主要负责任务的运行。下面把ResourceMana

2017-06-26 22:25:35 255

原创 LeetCode:Perfect Squares

Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n =

2017-06-26 21:41:05 183

原创 LeetCode:Path Sum II

Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and sum = 22, 5 / \

2017-06-26 19:43:10 213

原创 LeetCode: Path Sum

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree and sum

2017-06-26 19:36:24 193

原创 LeetCode:Convert Sorted List to Binary Search Tr

Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.给出一个单链表,结点是按元素递增的顺序排序,把链表转换成高度平衡的二叉搜索树解题分析:由于链表是按节结点的值递增排序的,因此可以使用双指针,一个快一个慢,

2017-06-26 19:31:59 262

原创 LeetCode:Search a 2D Matrix II

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 in ascending from left to right.Integers in

2017-06-26 16:54:18 236

原创 LeetCode: Kth Largest Element in 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.

2017-06-26 16:09:17 205

原创 如何使用Java实现简单的本地缓存?

我们知道,频繁的IO操作(包括网络请求、数据库请求等)是非常耗费时间资源的,同时也会极大的加重数据库等的压力,降低响应速度。因此对经常访问的数据做适当的缓存机制是非常有必要的。一般我们是通过key从缓存中读取value,如果读取不到则读取数据库,将数据库读取到的数据再放入缓存中。首先数据一般都是有一定的时效性的,也就是说,不是放入缓存中就一直都会存在,如果超过一定时间没有被使用则应当被清空,使

2017-06-26 15:30:42 2788

原创 浅谈Java中BIO、NIO、AIO的概念

首先从线程的角度来区分,BIO、NIO、AIO之间可以这么区分:BIO,同步阻塞式IO,简单理解:一个连接一个线程NIO,同步非阻塞IO,简单理解:一个请求一个线程AIO,异步非阻塞IO,简单理解:一个有效请求一个线程详细来讲:BIO在JDK1.4之前,用Java编写网络请求,都是建立一个ServerSocket,然后,客户端建立Socket时就会询问是否有

2017-06-26 15:24:14 290

原创 Hadoop-ssh免密码登录原理

在配置hadoop中,经常会有好几台机器组成一个分布式集群,各个机器之间的通信通常需要使用ssh的方式进行连接。正常情况下,我们连接登录机器的时候是需要输入IP、用户名、密码等等的信息,但是由于经常需要频繁地连接,因此若每次都需要输入这些信息那就太过繁琐了,因此最好将集群各个机器配置免密码登录。下面简单将一下免密码登录的原理:首先讲一下计算机网络安全中的加密机制,当前的加密类型可以概括

2017-06-26 10:13:37 815 1

原创 LeetCode: 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. Y

2017-06-25 21:02:07 242

转载 浅析RPC远程过程调用基本原理

在校期间大家都写过不少程序,比如写个hello world服务类,然后本地调用下,如下所示。这些程序的特点是服务消费方和服务提供方是本地调用关系。而一旦踏入公司尤其是大型互联网公司就会发现,公司的系统都由成千上万大大小小的服务组成,各服务部署在不同的机器上,由不同的团队负责。这时就会遇到两个问题:1)要搭建一个新服务,免不了需要依赖他人的服务,而现在他人的服务都在远端,怎么调用?2)其它团

2017-06-24 11:42:17 16496 1

原创 进程间通信、线程间通信的各种方式

操作系统的主要任务是管理计算机的软件、硬件资源。现代操作系统的主要特点是多用户和多任务,也就是程序的并行执行,windows如此linux也是如此。所以操作系统就借助于进程来管理计算机的软、硬件资源,支持多任务的并行执行。要并行执行就需要多进程、多线程。因此多进程和多线程间为了完成一定的任务,就需要进行一定的通信。而线程间通信又和进程间的通信不同。由于进程的数据空间相对独立而线程是共享数据空间的,

2017-06-24 10:43:42 496

原创 Web开发中服务器转发方式forward和redirect的区别

用户向服务器发送了一次HTTP请求,该请求可能会经过多个信息资源处理以后才返回给用户,各个信息资源使用请求转发机制相互转发请求,但是用户是感觉不到请求转发的。根据转发方式的不同,可以区分为直接请求转发(Forward)和间接请求转发(Redirect)两种有何区别呢?本篇在回答该问题的同时全面的讲解两种请求转发方式的原理和区别。Forward和Redirect代表了两种请求转发方式:直接转发和间接

2017-06-24 10:17:58 1772

原创 http中Post、Get方式的区别

简单理解,http中定义了客户端与服务器交互的几种方式,常见的有get和postget和post有两个主要的不同:1、get是从服务器上获取数据,而post则是向服务器传送数据2、get将表单中的参数按照var=value的形式,添加到action指定的URL后面,并且两者之间使用"?"进行连接,而各个参数之间使用“&”进行连接。 而post方法时将参数放在body中,按照变量

2017-06-24 10:11:15 281

原创 MySQL常见存储引擎对比

为什么数据库通常都有多种不同的存储引擎可以选用?数据库的存储引擎到底是什么东西?不同存储引擎的特点有什么区别?

2017-06-24 09:31:16 353

原创 LeetCode:Course Schedule

There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as

2017-06-23 21:23:34 153

原创 LeetCode:Edit Distance

Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2.(each operation is counted as 1step.)You have the following 3 operations permitted on word:1、In

2017-06-19 17:08:46 205

原创 LeetCode:Reorder List

Given a singly linked list L : L0 -> L1 -> ...Ln-1 -> Ln, reorder it to: L0 -> Ln ->L1 ->Ln-1 -> L2 -> Ln-2 ->....You must do this in-place without altering the nodes' values.For example, Given {1

2017-06-12 10:44:47 158

原创 LeetCode:Rotate Image

You are given an n*n 2D matrix representing an image.Rotate the image by 90 degrees(clockwise).Follow up: Could you do this in-place?解题思路:暴力法:从外到内一圈一圈地转,不过这个方法效率太低,比较慢。分析法:首先沿着副对角线翻转一次,然后沿着水

2017-06-03 09:19:48 208

原创 LeetCode: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->1

2017-05-28 13:47:26 242

原创 LeetCode: 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 c

2017-05-25 10:59:15 179

原创 LeetCode:Contains Duplicate

Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element

2017-05-14 20:15:42 177

原创 LeetCode: Subtree of Another Tree

Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a tree consists of a node in s and all of

2017-05-08 23:35:37 220

原创 LeetCode:Is Subsequence

Given a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000) strin

2017-04-29 18:20:29 213

原创 LeetCode: Top K Frequent Elements

Given a non-empty array of integers, return the k most frequent elements.For example,Given [1,1,1,2,2,3] and k = 2, return [1,2].Note: You may assume k is always valid, 1 ≤ k ≤ number

2017-04-23 15:31:41 188

原创 LeetCode:Odd Even Linked List

Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do it in

2017-04-15 19:05:08 229

原创 LeetCode: Move Zeroes

Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling you

2017-04-15 13:58:17 196

原创 LeetCode:Ugly Number

Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly sinc

2017-04-02 23:02:58 359

原创 LeetCode:Single Number

Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. 给出一个整型数组,其中除了一个元素之外,其他元素均出现两次,要求找出这个只出

2017-03-25 23:19:10 401

空空如也

空空如也

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

TA关注的人

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