05 2015 档案
摘要:一.HashMap的实现机制 1.HashMap是基于哈希表的map接口的非同步实现。HashMap相当于一个数组,数组的每个元素为一个链表。 2.向HashMap中插入一个Entry时,先计算Key的hashcode,根据hashcode确定Entry在数组中的位置,再根据equals判断是否...
阅读全文
摘要:【题目】 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 adj...
阅读全文
摘要:1. 统计工具wc -w : 单词数 ;-l :行数2. 解压 tar -xvf file.tar tar -zxvf file.tar.gz tar -jxvf file file.tar.bz2 tar -Zxvf file.tar.Z unrar file.rar unzip f...
阅读全文
摘要:【题目】Given two stringssandt, determine if they are isomorphic.Two strings are isomorphic if the characters inscan be replaced to gett.All occurrences o...
阅读全文
摘要:【题目】 删除一个整数链表里值为val的所有元素 举例: 假设有: 1-->2-->6-->3-->4-->5-->6 , val=6 返回有: 1-->2-->3-->4-->5【分析】 1. 链表删除问题 2. 把思路理清,多设几个指针。【算法实现】/** * Definition...
阅读全文
摘要:【题目】 写一个算法判断一个数是否"happy" 一个"happy"数的定义如下:开始于任意一个正整数,将该数替换为所有位上的数的平方和,然后重复这个过程直到这个数等于1,或者它可能无限循环(不包括1),这些结束于1的为"happy"数 举例: 19是一个"happy"数 12+92=8...
阅读全文
摘要:【题目】 你有n门课程需要完成,记为0到n-1。 有些课程需要先完成预备课程,例如你在完成课程0前需要先完成课程1,记为对[0,1]。 假如给定了课程总数以及所有预备关系对,返回完成所有课程的序列。 可能有多个正确序列,你需要返回其中一种。如果不能完成所有课程,就返回空数组。 举例:...
阅读全文
摘要:【题目】 你有n门课程需要上,几位0到n-1. 有些课程需要一些预备课程,例如:上课程0前需要先上课程1,表示为对[0,1] 假设给你所有课程和这些课程的对关系,有可能上完所有课程吗? 举例: 2 , [[1,0]] 这有2个课程需要完成,完成课程1前需要完成课程0,...
阅读全文
摘要:【题目】 假定给出一个有n个正整数的数组num和一个正整数s,找出一个子数组使其和sum大于s并返回子数组最小长度。如果不存在就返回0 举例:数组[2,3,1,2,4,3]和s=7 子数组[4,3]满足条件【分析】 1. 首先想到是两层for循环的方式,明显不会AC 2. 优化的方...
阅读全文
摘要:【题目】Given a list of non negative integers, arrange them such that they form the largest number.For example, given[3, 30, 34, 5, 9], the largest formed...
阅读全文
摘要:JVM内存模型一.内存模型堆和方法区是所有线程共享的,而虚拟机栈、本地方法栈和程序计数器是线程私有的。程序计数器:相当于程序指针,指向当前执行的java字节码的位置。是java内存中唯一不存在内存溢出和栈溢出的地方。虚拟机栈:执行java方法时,方法的调用与返回对应于栈帧的入栈与出栈。本地方法栈:与...
阅读全文
摘要:【单例模式】 单例设计模式的主要目的是:在整个系统中只能出现一个类的实例。比如全局配置信息,一个Factory,或者是一个主控类public class Singleton { private static Singleton singleton = new Singleton; ...
阅读全文
摘要:【一些设置】1.eclipse里的中文注释比较小 Window --> Preferences --> General --> Appearance --> Colors and Fonts --> Basic --> Text Font --> Edit如果在新版eclipse中中文注释明显小于...
阅读全文
摘要:【题目】Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not pos...
阅读全文
摘要:【题目】You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?【analyze】1.先对角线...
阅读全文
摘要:【资源导航】1.[StackOverFlow]2.[GitHub]3.[CsdnCode]4.[TaoCode]5.[OSChinaCode]【开源导航】【博客导航】【学习导航】1.[慕课网](慕课网-国内最大的IT技能学习平台)2.[极客学院](极客学院IT在线教育平台)3.[网易云课堂](云课堂...
阅读全文
摘要:【题目】Givennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after rainin...
阅读全文
摘要:【题目】Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "ad...
阅读全文
摘要:【题目】Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initi...
阅读全文
摘要:【题目】Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4]...
阅读全文
摘要:【题目】Given an unsorted integer array, find the first missing positive integer.For example,Given[1,2,0]return3,and[3,4,-1,1]return2.Your algorithm shoul...
阅读全文
摘要:【题目】Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints...
阅读全文
摘要:【题目】Given a collection of intervals, merge all overlapping intervals.For example,Given[1,3],[2,6],[8,10],[15,18],return[1,6],[8,10],[15,18].【analyze】1...
阅读全文
摘要:【Comparable和Comparator源码】java.lang.Comparable public interface Comparable { public int comparaTo(T o);}-----------------------------------------...
阅读全文
摘要:【题目】 Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in t...
阅读全文
摘要:本科的时候接触过SSH框架,但对原理没怎么研究过。只对Struts了解的稍微多点,介于YSP项目涉及到了SSH框架,由此来学习下。【总结】 1.hibernate反向工程,用来生成hibernate映射文件和POJO类 2.主要的一些配置文件 手动配置http://blog.csdn....
阅读全文

浙公网安备 33010602011771号