自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

do_smile的学习笔记

恰如猛虎卧荒丘, 潜伏爪牙忍受

  • 博客(77)
  • 收藏
  • 关注

原创 Log4J

在程序的开发过程中,可以使用debug打断点来调试程序,观察程序的运行情况。那代码上线之后,怎么看程序的运行情况呢?打log。 1、 程序log的几处应用: 定位问题 观察程序的运行状态 统计 log的三大组件: Logger:输入日志的具体内容 Appender:输出到哪里 Layout:输出日志的样式 2、打log的方式: 打log无非

2017-02-14 19:55:23 270

原创 Scalable IO in Java

阻塞IO的server结构图: 阻塞IO的server版本代码: class Server implements Runnable { public void run() { try { ServerSocket ss = new ServerSocket(PORT); while (!Thread.inter

2017-02-14 19:51:00 920

原创 MySQL的索引

每一个索引就对应着一棵树 (1) 主键:MySQL会以主键的值构造一棵树,其叶子节点存放着该主键对应的整行数据。因此一张表在数据结构上就等价于一颗以主键排序好的树 (2)辅助索引:自己建的索引一般都叫辅助索引,辅助索引树的叶子节点存放着两样东西,即辅助索引字段的值以及它所对应的主键值。因此当走辅助索引时,先从辅助索引树找到所需的主键,再到主键树上取出整行数据中的所需字段。举个例子,设ID为主键

2016-05-31 19:27:10 372

原创 Git的操作与理解

工作树:其存储着仓库内所有被管理文件 (untracked files是不记录在工作树中的) 的当前状态,随各文件的的改动而实时变化 HEAD : 当前分支中最新一次提交的指针 暂存区:提交之前的临时区域 (工作区 -add-> 暂存区 -commit-> 版本库) git init        : 初始化仓库,即为项目生成(.git) git status   : 查看仓库状

2016-05-31 17:21:21 284

原创 阿里校招内推总结

内推的蚂蚁金服Java研发岗,从7月15日第一面到7月31的hr面,共计4轮技术面,一轮hr。于8月15日收到录用意向。 7.15,20:45,一面:大概聊了24分钟 自我介绍 问数据库3NF与BCNF的区别 问GC机制,如何使持久代溢出 问数据库事务的四个特性 讲Java并发,自己的理解,随便讲 在平时是如何使用Java异常的 网络商城中各个模块怎么划分的,spring中

2015-08-29 10:40:08 712

原创 Executor框架的简要分析

Executor框架的最大优点是把任务的提交和执行解耦,ExecutorService和其各种功能强大的实现类提供了非常简便方式来提交任务并获取任务执行结果,封装了任务执行的全部过程。而封装最大的效果是使得真正执行任务的线程们变得不为人知。使得操作友好,不用程序员关心具体的执行,只需要等结果就行了。 比如用Executor.submit(Callable)返回Future,再调用Future.g

2015-08-06 14:12:08 467

原创 Java 8 中的ConcurrentHashMap源码分析

在HashMap的分析中,介绍了hashmap不是线程安全的,其在并发环境使用fail-fast策略来抛出由并发错误导致的异常。 先来看下Hashtable这个线程安全的容器,其虽然是线程安全的,但是其实现并发安全的手段比较粗暴。从下面的三个方法就能看出来,其只是简单的以自身作为对象锁,将相关方法都声明为synchronized,故每次只有一个线程能调用这些同步方法。 //Hash

2015-07-16 14:41:41 7198 6

原创 代理模式、动态代理与AOP

先来说说代理模式(静态代理): 其为23种设计模式之一,属于结构型模式,其主要思想是通过一个代理对象来代替真实对象来响应client的调用或请求。静态代理要求代理类与真实类实现一个共同的接口,这样代理对象才能在“型”上代替真实对象。类图如下: 一个通过代理模式来代理并增强真实对象的简单示例: //定义代理类与真实类的公共接口 public interface Subject

2015-07-15 20:34:24 669

原创 Java 8 中HashMap源码分析

HashMap的系统介绍: HashMap实现了Map接口(注意:map类容器都没有实现Collection接口,只有set,list这类的容器才实现Collection),其对一般的基本操作(put,get,contains)能够保证常数时间,当然前提是hash function能让各个key分布的均匀。然而HashMap不能维护其内对的顺序,也不保证其中的顺序是一直不变的。 有两个

2015-07-12 20:51:16 686

原创 Java中的泛型

所谓泛型,就是指编程语言中能够编写出更加“通用”、“泛化”的代码。希望能利用泛型,编写出一个能处理各种各样类型对象实例的处理过程代码。 首先,考虑下面一段通用代码: public class SimpleHolder { //一个简单的通用的容器 private Object obj; //利用Object来达到通用性 pub

2015-07-07 16:22:50 327

原创 LeetCode | Rotate List

Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL. /** * Definition for singly-linked

2015-07-01 14:38:40 307

原创 LeetCode | Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo

2015-06-30 11:25:55 293

原创 LeetCode | Minimum Window Substring

Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example, S = "ADOBECODEBANC" T = "ABC" Minimum window is "BAN

2015-06-29 20:44:11 300

原创 LeetCode | Contains Duplicate III

Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] and nums[j] is at most t and the difference between i an

2015-06-28 20:18:31 548

原创 LeetCode | Contains Duplicate II

Given an array of integers and an integer k, find out whether there there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between iand j is at most

2015-06-28 09:53:22 438

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

2015-06-28 09:28:51 445

原创 LeetCode | Find Minimum in Rotated Sorted Array II

Follow up for "Find Minimum in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time complexity? How and why? Suppose a sorted array is rotated at some pivot u

2015-06-27 11:19:12 306

原创 LeetCode | Find Minimum in Rotated Sorted Array

Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find the minimum element. You may assume no duplicate exists in

2015-06-27 10:59:03 234

原创 LeetCode | Search in Rotated Sorted Array II

Follow up for "Search in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time complexity? How and why? Write a function to determine if a given target is in the

2015-06-25 15:38:33 304

原创 LeetCode | Search in Rotated Sorted Array

Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target value to search. If found in the array retur

2015-06-24 19:46:41 291

原创 Java中的RTTI与反射

个人理解,可能有误。理解自《java编程思想》。 首先,什么是RTTI? RTTI(run-time type information)指的是Java在运行时能够获得或判断某个对象的类型信。以Shape, Circle, Squre, Triangle为例,后三者继承shape。 主要由三种方式: (1)转型:(Type) realType Java中,允许自由的upcast

2015-06-24 17:02:35 741

原创 LeetCode | Divide Two Integers

Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. 要求不使用乘法、除法或模运算实现: dividend/divisor,也就是只能用加、减或位运算。int的取值范围[-2147483648, 2147483647],即

2015-06-22 14:43:49 335

原创 LeetCode | Pow(x, n)

Implement pow(x, n). //tag提示用binary search,主要就是确定有多少个x来相乘。 //思想是对n进行二分。注意下n可能为负数 public class Solution { public double myPow(double x, int n) { if(n == 0) return 1; dou

2015-06-21 14:52:34 288

原创 LeetCode | Sqrt (x)

Implement int sqrt(int x). Compute and return the square root of x. //tag提示用binary search。要求的返回结果是int,不是实际的平方跟,用二分法找到最合适的int就行 public class Solution { public int mySqrt(int x) { if(x <

2015-06-21 11:35:53 245

原创 LeetCode | 3 Sum

Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: Elements in a triplet (a,b,c

2015-06-18 18:39:15 255

原创 LeetCode | Two Sum

Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, whe

2015-06-17 16:29:47 227

原创 LeetCode | Pascal's Triangle II

Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3,3,1]. Note: Could you optimize your algorithm to use only O(k) extra space? 按昨天的思路,不考虑空间复杂度的

2015-06-16 15:12:53 230

原创 LeetCode | Pascal's Triangle

Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] //杨辉三角:每一行,头尾为1,中间元素为其上一行两肩位

2015-06-15 11:06:31 255

原创 LeetCode | Invert Binary Tree

Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 Trivia: This problem was inspired by this original tweet by Max Howe

2015-06-13 15:12:56 298

原创 LeetCode | Plus One

Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list. //思想类似于前两天的add binary与

2015-06-12 10:22:58 219

原创 LeetCode | Longest Common Prefix

Write a function to find the longest common prefix string amongst an array of strings. //要求找到字符串数组中所有string的最长公共前缀 //用brute force的方法,取第一个字符串的每一个字符来遍历数组 public class Solution { public String lo

2015-06-11 19:54:47 282

原创 LeetCode | Add Two Numbers

You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link

2015-06-10 18:39:26 322

原创 LeetCode | Add Binary

Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". //思想是从后向前,从低位开始逐位相加,结果放到一个StringBuilder中,并用carry来表示是否有进位 //某个字符串用光之后,另一个字符串的剩余部分加上car

2015-06-09 13:03:37 288

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

2015-06-07 10:38:29 274

原创 排序算法总结

排序方法: public class SortMethods { /* -------- 插入排序 -------- */ //原理:将数组分为前后两个部分,每次从后面的未排序的部分中取出最前面的一个元素,插入到前面已经排序好的部分的合适位置处。 public void insertSort(int[] A) { for (int i = 0; i < A.length; i++)

2015-05-10 21:29:23 294

原创 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-05-10 15:32:40 286

原创 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 house

2015-05-04 11:10:21 207

原创 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-05-03 11:33:01 232

原创 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 reach the

2015-04-27 19:41:00 333

原创 LeetCode | Unique Binary Search Trees II

Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example, Given n = 3, your program should return all 5 unique BST's shown below. 1 3

2015-04-26 13:42:21 299

空空如也

空空如也

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

TA关注的人

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