自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(44)
  • 资源 (3)
  • 收藏
  • 关注

原创 sort list

Sort a linked list in O(n log n) time using constant space complexity.ListNode getMiddleOfList(ListNode head) {          ListNode slow = head;          ListNode fast = head;          while

2015-03-31 21:21:06 348

转载 Amazon的概率面试题

该问题包含两个子问题:子问题1:给你一个骰子,你扔到几,机器将会给你相应的金钱。比如,你扔到6,机器会返回你6块钱,你扔到1,机器会返回你1块钱。请问,你愿意最多花多少钱玩一次?子问题2:在子问题1里,你只能扔一次,现在呢,可以给你两次机会,但是你自己也可以选择只扔一次。但返回的钱以最后一次为准。比如,第一次你扔了6,你把第二次机会就放弃了,这样机器会返给你6块钱。但是,假设你

2015-03-30 17:18:45 1937

转载 Servlet请求转发 RequestDispatcher接口

在Servlet中,利用RequestDispatcher对象,可以将请求转发给另外一个Servlet或JSP页面,甚至是HTML页面,来处理对请求的响应。一,RequestDispatcher接口方法简介       1,RequestDispatcher对象由Servlet容器来创建,封装一个由路径所标识的服务器资源。         2,RequestDispatch

2015-03-30 15:38:05 349

原创 spring学习笔记

1、在spring中,每一个被实例化为一个BeanDefinition,然后保存到容器中的map里。2、容器的初始化就是BeanDefinition的Resource的定位、载入和注册三个基本过程,但他们用不同的模块来实现,通过这样的设计,可以让用户更加灵活的对三个过程进行剪裁和扩展。

2015-03-27 19:33:33 300

转载 jdk动态代理和CGlib动态代理

Jdk动态代理,CGLib字节码生成如果目标对象实现了接口,可以使用jdk动态代理和CGLib。如果没有实现接口,只能使用CGLib。一,jdk动态代理1.java动态代理用到了一个类(Proxy)和一个接口(InvocationHandler)2.jdk动态代理是通过实现目标类所实现的接口来产生代理类并生成代理对象的3.类Proxy:该类用于创建目标类的代理对象。Pr

2015-03-27 16:32:57 375

转载 Palindrome Partitioning I II

Palindrome Partitioning I Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For example, given s =

2015-03-27 11:32:40 341

转载 Gas Station

There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to

2015-03-27 10:56:11 307

转载 Best Time to Buy and Sell Stock IV

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 at most k transactions.解题思路采用动

2015-03-26 19:53:27 340

转载 Longest Valid Parentheses

Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()",

2015-03-23 10:19:04 311

转载 Sudoku Solver

public class Solution {    public void solveSudoku(char[][] board) {        solve(board);               }      private boolean solve(char[][] board) {           for (int i = 0; i        

2015-03-23 10:05:24 325

转载 Median of Two Sorted Arrays

将原问题转变成一个寻找第k小数的问题(假设两个原序列升序排列),这样中位数实际上是第(m+n)/2小的数。所以只要解决了第k小数的问题,原问题也得以解决。首先假设数组A和B的元素个数都大于k/2,我们比较A[k/2-1]和B[k/2-1]两个元素,这两个元素分别表示A的第k/2小的元素和B的第k/2小的元素。这两个元素比较共有三种情况:>、证明也很简单,可以采用反证法。假设A[k/

2015-03-21 15:03:13 292

转载 Permutation Sequence

方法一:可以一个一个的按次序求排列。使用Next Permutation:http://blog.csdn.net/doc_sgl/article/details/11803389方法二:数学解法在n!个排列中,第一位的元素总是(n-1)!一组出现的,也就说如果p = k / (n-1)!,那么排列的最开始一个元素一定是nums[p]。假设有n个元素,第K个perm

2015-03-19 11:34:29 329

转载 Multiply Strings

利用竖式的思想,进行乘法运算。        3    4*      1    3——————       9      123     4——————3     13     12再处理进位:3 13 12 - > 3 14 2 -> 4 4 2public class Soluti

2015-03-19 11:27:24 279

转载 Repeated DNA Sequences

View Codehash table plus bit manipulation method(view the Show Tags and Runtime 10ms !)算法分析首先考虑将ACGT进行二进制编码A -> 00C -> 01G -> 10T -> 11在编码的情况下,每10位字符串的组合即为一个数字,且10位

2015-03-19 10:36:00 325

原创 动态规划

用动态规划的方法,就是要找到其转移方程式,也叫动态规划的递推式,动态规划的解法无非是维护两个变量,局部最优和全局最优。其中局部最优的意思就是到目前这个数字为止,其最好的值,整体最优就是整体的最好值。例子:Maximum Product Subarray Find the contiguous subarray within an array (containing

2015-03-18 11:07:09 320

原创 Subsets II

Given a collection of integers that might contain duplicates, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain dupli

2015-03-18 10:46:41 289

转载 Java的无锁编程和锁优化

http://blog.csdn.net/raychase/article/details/6667141在这篇文章里面已经提到了三件事情:1、Peterson 算法,2、ConcurrentHashMap,3、无锁编程的初识。 如果站在语言层面之上,仅从设计的层面看,可以避免锁的思路至少包括:1、单线程来主导行为,多线程池化操作避开状态变量。比如在一个

2015-03-15 10:02:42 782

转载 Copy List with Random Pointer

1. 在OldList中的每个结点后,插入一个CopyNode,这个结点的Random域和Next域与OldList中的被拷贝Node的Random域和Next一致,然后让被拷贝结点的Next域指向CopyNode结点,这样先创建出OldList中结点对应的CopyNode结点。2. 由于所有的CopyNode都已经创建出来了,我们就可以调整这些CopyNode真正的Random域的值了。

2015-03-14 20:27:01 322

转载 Longest Substring Without Repeating Characters

O(n2)的解法是最为直接的:1.枚举每一个子串;2.扫描子串,求出满足题意的最长长度。int max = 0;char *t;for (int i = 0; i     t = &s[i];    int j = 0;    while (j         j++;    }    if (j > max) {       

2015-03-14 09:44:49 305

转载 Regular Expression Matching

Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input st

2015-03-13 19:41:26 274

转载 【LeetCode】Largest Number 解题报告

http://blog.csdn.net/ljiabin/article/details/42676433【题目】Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5,

2015-03-13 15:46:57 355

转载 Eucalyptus

我的网络会变得更快吗?By qyjohn, January 16, 2013 9:16 am译者注:最近Eucalyptus公司的联合创始人Graziano Obertelli连续写了几篇关于云服务的可维护性方面的博客文章。译者读后觉得很受启发,并决定花点时间将这几篇文章翻译成中文。这些博客文章的原始出处如下:[1] http://gobertelli.blogspot.com/2012/12/i

2015-03-13 15:28:44 438

转载 名企笔试题

分类: 名企笔试题2013-06-26 11:50 70人阅读 评论(0) 收藏 举报腾讯1、计算表达式x6+4x4+2x3+x+1最少需要做()次乘法A、3                 B、4                  C、5                       D、62、给定3个int类型的正整数x,y,z,对如下4组表达式判

2015-03-13 15:26:40 1044

转载 Maximum Gap

比较排序的时间复杂度是O(nlogn),而题目要求O(n)。可用的排序算法有桶排序、计数排序、基数排序/ 用桶排序 // 算出相邻两个桶之间的最大差值 // 如果是平均分布,则桶的数目和元素的数目相同时,其排序的时间复杂度是0(n) // 我们假设桶的个数和元素的数目相同,若是平均分布,则每个桶里有一个数,而若某个桶里有两个以上的桶时,这时必有至少一个是空桶,那么最

2015-03-13 15:25:24 409

转载 4Sum

public List> fourSum(int[] num, int target) {        Arrays.sort(num);  HashSet> hashSet = new HashSet>(); List> result = new ArrayList>();  for (int i = 0; i < num.length; i++) { for (

2015-03-13 09:29:28 331

转载 2Sum/3Sum/3SumClosest/4Sum系列问题

leetcode(http://leetcode.com/onlinejudge)上有好几道关于数组中几个数据和为target的题目。恰好正在看剑指offer中“和为s的两个数组这章”,据此思想,leetcode上的三道题目都被我解决了。总结一下。1.twoSum:输入一个递增数组和一个数字s,在数组中查找两个数使得它们的和正好是s。既然题目中已经提到了“递增数组”,那么肯定不会暴

2015-03-13 09:18:16 414

原创 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-03-12 16:08:01 355

转载 Java中的10颗语法糖

http://blog.sina.com.cn/s/blog_9eb66d350101247n.html语法糖(Syntactic Sugar):也称糖衣语法,指在计算机语言中添加的某种语法,这种语法对语言的功能没有影响,但是更方便程序员使用。通常来说,使用语法糖能够增加程序的可读性,减少程序代码出错的机会。Java中的语法糖包括但不限于以下10颗:泛型与类型擦除、自动装箱和拆

2015-03-12 10:47:53 432

转载 Java静态多分配,动态单分配

http://blog.csdn.net/cclive1601/article/details/8050330http://my.oschina.net/tdd/blog/341258class Human{}  class Man extends Human{}class Woman extends Human{}public class StaticPai{

2015-03-12 10:42:48 1927

转载 Permutation Sequence

http://blog.csdn.net/doc_sgl/article/details/12840715The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get th

2015-03-11 09:29:42 336

转载 深入研究Java类加载机制

http://blog.csdn.net/love_Javc_you/article/details/38081683深入研究Java类加载机制 类加载是Java程序运行的第一步,研究类的加载有助于了解JVM执行过程,并指导开发者采取更有效的措施配合程序执行。研究类加载机制的第二个目的是让程序能动态的控制类加载,比如热部署等,提高程序的灵活性和适应性

2015-03-10 21:49:59 293

原创 类加载过程

1、加载。虚拟机主要完成以下三件事:(1) 通过类的全限定名来获取类的二进制流。(2)将这个字节流所代表的静态存储结构转化为方法区的运行时数据结构。(3)在java堆中生成一个代表这个类的Class对象,作为方法区这些数据的访问入口。2、验证。保证class文件的字节流正确性。3、准备。正式为类变量分配内存并设置类变量初始值的阶段,这些内存都将在方法区中分配。仅分配

2015-03-10 20:44:38 449

转载 Java 中对类的主动引用和被动引用

http://blog.csdn.net/anialy/article/details/8175213简述:看了《深入Java虚拟机》一书中关于“类是否初始化?“ 这一问题的探讨后,觉得有必要亲手做下总结在实际代码中, 有些类可能看上去时初始化了,但实际上并没有。举个例子,对于一个类Fruit, 声明一个fruit[] 数组,看上去是很多个Fru

2015-03-10 20:38:36 616

原创 Subsets II

Given a collection of integers that might contain duplicates, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain dupli

2015-03-10 16:58:41 306

转载 Scramble String

Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = "great": great / \ gr

2015-03-10 15:10:56 343

转载 Unique Binary Search Trees II

http://www.tuicool.com/articles/JJVbA3U题目 :Given n , generate all structurally unique BST's (binary search trees) that store values 1... n .For example,Given n = 3, your program sh

2015-03-10 11:21:35 344

转载 Unique Binary Search Trees [动态规划]

如果集合为空,只有一种BST,即空树,UniqueTrees[0] =1如果集合仅有一个元素,只有一种BST,即为单个节点UniqueTrees[1] = 1UniqueTrees[2] = UniqueTrees[0] * UniqueTrees[1]   (1为根的情况)+ UniqueTrees[1] * UniqueTrees[0]  (2为根的情况。

2015-03-10 10:48:55 477

转载 Java字面量(Java直接量)和符号引用

1、Java字面量(Java直接量)int i = 1;把整数1赋值给int型变量i,整数1就是Java字面量,同样,String s = "abc";中的abc也是字面量。数据类型直接量描述举例int整数直接量(可用二、十、八、十六进制表示)12-12+12

2015-03-09 10:50:39 17956 1

转载 Comparable与Comparator的区别

http://blog.csdn.net/mageshuai/article/details/3849143Comparable & Comparator 都是用来实现集合中元素的比较、排序的,只是 Comparable 是在集合内部定义的方法实现的排序,Comparator 是在集合外部实现的排序,所以,如想实现排序,就需要在集合外定义 Comparator 接口的方法或在集合内

2015-03-09 09:38:04 359

原创 Restore IP Addresses

Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255.11.135", "255.255.111.35"]. (Order

2015-03-07 18:33:03 349

jsp 网上商店

jsp网上商店,主要是网上书店,适合期末大作业。

2014-01-12

tomcat-7.0.26

apache-tomcat-7.0.26

2013-12-01

学生管理系统

这是个学生管理系统,大学课程设计,希望对大家有点帮助!

2013-05-27

空空如也

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

TA关注的人

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