自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Spring源码---BeanFactory接口体系分析

参考资源Spring源码解析-BeanFactory接口体系解读 BeanFactory接口体系源码分析下图为spring源码中BeanFactory接口体系结构spring的BeanFactory接口体系结构中,每个结构实现特定功能,这个满足设计模式的原则:接口隔离原则 下面我们来逐个分析每个接口的源码BeanFactory接口/*1.这个根接口可访问...

2018-08-22 20:12:48 631

原创 java异常

java的异常机制Throwable类Throwable类是Java异常类型的顶层父类,一个对象只有是 Throwable 类的(直接或者间接)实例,他才是一个异常对象,才能被异常处理机制识别。JDK中内建了一些常用的异常类,我们也可以自定义异常。Throwable又派生出Error类和Exception类。错误:Error类以及他的子类的实例,代表了JVM本身的错误。错误不能被程...

2018-07-25 16:20:53 293

原创 java内部类

概念内部类:可以包含在另外一个类中的类外部类:包含内部类的类 每个内部类都会被编译为一个独立的类,生成一个独立的字节码文件。内部类可以方便地访问外部类的私有变量,内部类也可以声明为private从而实现对外完全隐藏。 分类java中的四种内部类(根据定义的位置和方式划分)-静态内部类-成员内部类-方法内部类-匿名内部类 分类介绍-静态内部...

2018-07-24 15:41:56 188

原创 java的继承

继承1.java中是单继承的。每个子类只有一个父类。   语法:子类 extends 父类2.在java中,即使没有声明父类,也有一个隐含的父类,就是Object类3.在子类中可以使用super来调用父类的方法 4.继承中的构造方法问题在new一个子类实例的过程中,会优先自动调用父类默认的无参数构造方法,然后再调用子类的构造方法。如果父类没有默认的构造方法,只有带参数的...

2018-07-23 14:53:46 215

原创 java的动态绑定和静态绑定

背景1.当子类和父类存在同一个方法,子类重写了父类的方法,程序在运行时调用的是父类的方法还是子类的重写方法呢(尤其是存在向上类型转换的情况)?2.当一个类中存在方法名相同但参数不同(重载)的方法,程序在执行的时候该如何辨别区分使用哪个方法呢?在java中存在绑定的机制解决以上疑问。 绑定绑定:将一个方法的调用与方法所在的类(方法主体)关联起来。即决定调用哪个方法和变量。...

2018-07-23 10:58:10 6233 4

原创 回溯算法原理总结

回溯算法理论总结回溯法是一种类似枚举的搜索尝试过程,既然是枚举,那么就会遍历解空间树中的所有解(或者是“路径”),搜索的过程按照DFS原则,而尝试就意味着,在遍历的过程中,有可能到达某一个结点后,发现不能够满足约束条件,在这次尝试中,这条“路”是不优的,将走不通,即无法找到所求的解,那么就会回退到上一步的状态,重新作出选择。如果即满足约束条件,但是依然没有获得有效的解,那么我们就需要在此基础上...

2018-07-19 19:29:09 3417

原创 动态规划算法

动态规划基础理论 动态规划,指通过组合子问题的解来求解原问题。动态规划算法的核心是记住已经解决过的子问题的解。 与分治方法的区别:分治方法将问题划分为互不相交的子问题,递归地求解子问题,再将它们的解组合起来,求出原问题的解。动态规划应用于子问题重叠的情况,即不同的子问题具有公共的子子问题(子问题的求解是递归进行的,将其划分为更小的子子问题)分治算法会做许多不必要的工...

2018-07-17 20:28:01 421

原创 java中Stack类的介绍

本文主要对java中的Stack源码进行分析。1.Stack类在java.util包中;2.源码顶部注释分析3.继承关系Stack继承了Vector,而Vector类底层使用数组存储数据,那么Stack对象中存储的数据也是存储在数组中的。4.构造函数Stack只有一个无参数的构造函数。5.API介绍(1)push(item):把数据压入栈addElement()是父类Vector中的方法,会将压入...

2018-07-06 16:41:25 4397

原创 快速幂算法

原理介绍快速幂的目的就是做到快速求幂,假设我们要求a^b,按照朴素算法就是把a连乘b次,这样一来时间复杂度是O(b)也即是O(n)级别,快速幂能做到O(logn)。我们可以对指数b拆分:(1)如果b为偶数,那么a^b = (a^2)^(b/2);(2)如果b为奇数,那么a^b = a * (a^2)^(b-1)/2);(3)如果b/2为偶数,那么a^b = ((a^2)*(a^2))^(b/4);...

2018-07-04 21:10:16 444

原创 迭代和递归的区别

概念递归:程序调用自身的编程思想,即一个函数调用本身。一个函数在其定义中直接或间接调用自身的一种方法,它通常把一个大型的复杂的问题转化为一个与原问题相似的规模较小的问题来解决,可以极大的减少代码量.递归的能力在于用有限的语句来定义对象的无限集合。使用递归要注意的有两点:1)递归就是在过程或函数里面调用自身;2)在使用递归时,必须有一个明确的递归结束条件,称为递归出口。递归分为两个阶段:1)递推:把...

2018-07-03 19:10:40 733

原创 排序算法汇总

1.冒泡排序参考链接:排序算法总结

2018-06-29 10:42:00 221

原创 堆数据结构

本帖中讲述的是堆数据结构,而不是垃圾收集存储什么是堆堆,这里指二叉堆,是一个数组,可以被看成一个近似的完全二叉树。树上的每一个结点代表数组中的一个元素。除最底层外,该树是完全充满的,而且是从左向右填充。(根据堆的填充顺序,只有将上一层填满,才能在下一层出现数据,因此对重除最底层的其他层中都已经被完全充满了)堆的一些属性现有下标为i的结点,父结点的下标为i/2;左子结点为2i;右子结点为2i+1。堆...

2018-06-28 16:06:07 1384

原创 Leetcode 67

英文原题Given two binary strings, return their sum (also a binary string).The input strings are both non-empty and contains only characters 1 or 0.Example 1:Input: a = "11", b = "1"Output: "100"Example 2...

2018-06-11 21:43:41 202

原创 Leetcode 168 Excel Sheet Column Title

原题Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> ...

2018-06-05 08:58:44 129

原创 Leetcode 58 Length of Last Word

原题Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is defined...

2018-06-03 23:41:53 190

原创 Leetcode38 Count and Say

原题The count-and-say sequence is the sequence of integers with the first five terms as following:1. 12. 113. 214. 12115. 1112211 is read off as "one 1" or 11.11 is read off as ...

2018-06-03 23:07:33 147

原创 Leetcode283 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.Example:Input: [0,1,0,3,12]Output: [1,3,12,0,0]Note:You must do ...

2018-05-29 11:21:43 140

原创 Leetcode167 Two Sum II - Input array is sorted

原题Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers ...

2018-05-29 10:13:00 128

原创 Leetcode119 Pascal's Triangle II

原题目Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle.Note that the row index starts from 0.In Pascal's triangle, each number is the sum of the two numbers di...

2018-05-26 16:48:30 190

原创 Leetcode66 Plus One

原文题目Given a non-empty array of digits representing a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and each eleme...

2018-05-18 09:26:39 236

原创 Leetcode35 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....

2018-05-17 22:59:41 149

原创 Leetcode122 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 (i.e., buy o...

2018-05-17 21:01:17 157

原创 leetcode121 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 (i.e., buy one and sell one share of the stock...

2018-05-11 10:05:21 127

原创 Leetcode70 Climbing Stairs

问题描述You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be a positive...

2018-05-10 19:17:58 135

原创 操作系统读书笔记-chap1

参考书目为:Operating System Concepts(9th Edition)第一章  操作系统概述操作系统可以看作用户和硬件之间的中间人,为用户方便有效地执行程序提供环境。操作系统本质就是能够管理计算机硬件的软件。计算机系统分为四部分:硬件、操作系统、应用程序和用户。硬件:中央处理器(CPU)+内存+I/O设备,为系统提供计算资源应用程序:定义了用户如何使用这些计算资源解决计算问题的方...

2018-03-08 23:00:20 183

原创 Leetcode172 Factorial Trailing Zeroes

题目Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.中文大意给定整数n,返回改整数阶乘n!结果的尾随零的个数分析直观的思路是:先求出阶乘结果n!,然

2018-03-05 14:50:28 173

原创 Leetcode398 Random Pick Index

题目Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array.Note:The array size can b...

2018-03-05 00:02:48 213

原创 Leetcode130 Surrounded Regions

题目Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For example,X X X XX O O ...

2018-03-03 23:11:33 259

原创 Leetcode628 Maximum Product of Three Numbers

题目Given an integer array, find three numbers whose product is maximum and output the maximum product.Example 1:Input: [1,2,3]Output: 6Example 2:Input: [1,2,3,4]Output: 24Note:The length of the giv...

2018-03-02 19:37:27 133

原创 Leetcode260 Single Number III

题目Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For example:

2018-03-02 09:24:20 160

原创 Leetcode643 Maximum Average Subarray I

题目Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to output the maximum average value.Example 1:

2018-02-28 20:14:40 199

原创 Leetcode553 Optimal Division

题目Given a list of positive integers, the adjacent integers will perform the float division. For example, [2,3,4] -> 2 / 3 / 4.However, you can add any number of parenthesis at any position

2018-02-28 19:55:37 221

原创 Leetcode661 Image Smoother

题目Given a 2D integer matrix M representing the gray scale of an image, you need to design a smoother to make the gray scale of each cell becomes the average gray scale (rounding down) of all the 8 sur...

2018-02-27 09:58:31 265

原创 Java多线程:Volatile关键字

volatile关键在是在java 5后得到完善后,才被推广使用的。java内存模型中对volatile型变量的特殊规则volatile关键字的使用方法:volatile关键字是java虚拟机提供的最轻量级的同步机制。volatile关键字的作用:当一个变量定义为volatile之后,它将具备两种特性:特性一:保证此变量对所有线程的可见性,这里的“可见性”是指当一条

2018-02-08 10:58:23 237

原创 java多线程:基础原理

java多线程:基础原理java支持多线程编程,为了能够深入理解java多线程机制,以及解决多线程的安全问题,本文介绍多线程的基础知识和原理分析。Part1 概念总结线程的概念线程(Thread)是操作系统能够进行运算调度的最小单位。它被包含在进程之中,是进程中的实际运作单位。一条线程指的是进程中一个单一顺序的控制流,一个进程中可以并发多个线程,每条线程并行执行不同的任

2018-02-05 16:58:00 2277 1

原创 Leetcode724 Find Pivot Index(数组的中间下标)

题目Given an array of integers nums, write a method that returns the "pivot" index of this array.We define the pivot index as the index where the sum of the numbers to the left of the index is equal to

2018-01-19 13:35:59 394

原创 Leetcode747 Min Cost Climbing Stairs(爬楼梯的最小代价)

题目:On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed).Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the top of

2018-01-19 10:04:45 391

原创 java之树的遍历

深度优先遍历(Depth First Search,DFS)和广度优先遍历(Breadth First Search)是两种遍历树中元素的方式。深度优先遍历(DFS):对于上述tree来说,DFS的遍历结果为:A B D E C F G如果某个节点有子节点和兄弟节点,那么优先遍历子节点,左子树优先于右子树,直到子树都被深度遍历后,然后再遍历兄弟节点及其子树。由于不会立马遍历

2018-01-18 11:10:58 698

原创 javascript之BOM的location对象

location对象location是最有用的BOM 对象之一,它提供了与当前窗口中加载的文档有关的信息,还提供了一些导航功能。 location对象是很特别的一个对象,因为它既是window对象的属性,也是document对象的属性;换句话说,window.location和document.location引用的是同一个对象。location对象的用处不

2018-01-05 15:46:50 297

原创 javascript之单线程

javascript的单线程机制为什么javascript采用单线程机制?        先说明一下线程和进程的不同:进程是执行的应用程序,每个进程都是由私有的虚拟地址空间、代码、数据和其它系统资源所组成,进程在运行过程中能够申请创建和使用系统资源,这些资源也会随着进程的终止而被销毁。线程是进程内的一个独立执行单元,在不同的线程之间是可以共享进程资源的,所以在多线程的情况下,需要特

2018-01-05 09:12:48 250

空空如也

空空如也

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

TA关注的人

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