- 博客(25)
- 资源 (2)
- 收藏
- 关注
原创 Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.非常直接的一题,运用set来chaja
2014-04-24 12:52:35
531
原创 Remove Element
Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond the new length.p
2014-03-30 04:51:23
576
原创 Maximum Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray [4,−1,2,1] ha
2014-03-30 04:41:54
663
原创 Pascal's Triangle
Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,public class Solution { public ArrayList> generate(int numRows) { ArrayList> lis
2014-03-30 04:14:39
600
原创 Linked List Cycle
Given a linked list, determine if it has a cycle in it.Link : 点击打开链接If the fast pointer can catch up the slow pointer again, means there is a cycle.public class Solution { public boolean has
2014-03-30 00:51:00
433
原创 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?Solution : recursive , like
2014-03-30 00:44:23
535
原创 Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.public class Solution {
2014-03-29 06:01:33
483
原创 Populating Next Right Pointers in Each Node
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right node.
2014-03-29 05:49:10
643
原创 Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,2].Use a stack data struct
2014-03-29 05:28:00
496
转载 Bloomberg面经
总共三轮第一轮俩人technical1. tweet has topics, find top 10 topics of tweets send in last 30 minutes2. leetcode 积水问题3. there are different kind of databases; given a query, system will tell you whi
2014-03-29 04:02:18
1256
原创 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 (ie, buy on
2014-03-29 01:31:34
703
原创 [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
2014-03-29 01:23:40
448
转载 Factory Model
一、工厂模式主要是为创建对象提供过渡接口,以便将创建对象的具体过程屏蔽隔离起来,达到提高灵活性的目的。 工厂模式在《Java与模式》中分为三类:1)简单工厂模式(Simple Factory):不利于产生系列产品;2)工厂方法模式(Factory Method):又称为多形性工厂;3)抽象工厂模式(Abstract Factory):又称为工具箱,产生产品族,但
2013-11-22 17:44:34
800
转载 Java singleton 7种模式
第一种(懒汉,线程不安全): 1 public class Singleton { 2 private static Singleton instance; 3 private Singleton (){} 4 public static Singleton getInstance() { 5 if (instance ==
2013-11-22 17:32:27
502
转载 Java程序打包成jar包
方法一:通过jar命令jar命令的用法:下面是jar命令的帮助说明:用法:jar {ctxui}[vfm0Me] [jar-file] [manifest-file] [entry-point] [-C dir] files ...选项包括: -c 创建新的归档文件 -t 列出归档目录 -x 解压缩已归档的指定(或所有)文件
2013-10-05 13:37:17
643
转载 JavaBean构件.
JavaBean就是一个可生用的构件,并可在开发工具中,如Netbeans中进行可视化的操作,与VB的可视化拖拽操作类似.有时候我们也会在jsp中使用简化的JavaBean.在Netbeans中使用时, 一般需要打包成Jar文件,并在清单中注明,尽量不要使用缺省包名.有时空格换行什么的会影响Bean的加载.Name: com/qp/Abean.classjava-Bean: TrueJ
2013-10-03 01:32:13
1043
转载 Visual Studio控制台程序输出窗口一闪而过的解决方法
刚接触 Visual Studio的时候大多数人会写个Hello World的程序试一下,有的人会发现执行结束后输出窗口会一闪而过,并没有出现Press any key to continue的字样。无论是在Visual Studio 2008、2010还是2012中都有这种情况出现,有些人可能会用下面两种方法中的一种: 在程序代码的最后加上system("pause")或者ge
2013-09-30 04:56:08
974
转载 Java design pattern: Adapter
Before01Because the interface between Line and Rectangle objects is incapatible, the user has to recover the type of each shape and manually supply the correct arguments.02class LegacyLine{
2013-09-22 23:32:15
484
原创 Mysql 数据库基本操作总结
创建数据库: create database [name];查看数据库::show databases;删除数据库: drop database [name];查看支持的数据库引擎:show engines; show variables like 'have%';查看默认引擎:show variables like 'storage_engine';
2013-09-21 13:27:13
557
原创 Hibernate 对象PO的save()与persist()方法的区别
Hibernate对象的三种状态,Hibernate对象是一种POJO.在程序运行过程中该对象可以有三种状态:瞬时状态:在对象被创建时,该对象处于瞬时状态,当该对象被取消引用时,该对象将被垃圾回收。持久化状态:瞬时状态的对象被Session所调用时,该对象变为持久化状态。托管状态:持久化状态的Session被关闭时,该对象处于托管状态。save() 方法返回一个对象的主键。
2013-09-21 10:21:11
1260
原创 Hibernate 链接数据库中的数据源
数据源是一种提高数据库访问性能的手段,数据源负责维持一个数据库链接池,当程序创建一个数据源时,会同时创建多个数据库链接,并将这些数据库连接放入连接池中。当程序需要进行数据库访问时,可以直接用,用完之后再放回数据库连接池。这种方式可以避免频繁的获取数据库链接和关闭数据库链接,达到提高性能的目的。
2013-09-21 08:11:15
720
转载 张孝祥整理Java面试题
一. Java基础部分......................................................................................................21、一个".java"源文件中是否可以包括多个类(不是内部类)?有什么限制?.....22、Java有没有goto?........................
2013-09-20 05:41:23
12801
4
原创 Java 中类加载的方式
Java 中类加载的方式1.从本地文件系统加载class文件2.从JAR包中加载class文件3.通过网络加载class文件4.把一个Java源文件动态编译并执行Java中类属性的初始化:1.在定义时初始化2.在静态初始化快中初始化 没有被初始化的静态属性默认为0或null类实例化的方法:1.通过new 2.同过反序列化3.通过反射反射: Fie
2013-09-20 05:36:54
938
原创 Java 读书笔记
1.java 浮点数: 只有浮点数除以0才可以得到正无穷大和负无穷大,因为Java会自动将0转换成0.0。如果一个整数除以0,则会抛出一个异常。ArithmeticException by zero2.float a = 5.6.错误,应为5.6默认是double类型。float a = (float)5.6.3.System.out.println('a'+7+"hello");结果为1
2013-09-20 02:06:59
613
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人