- 博客(19)
- 收藏
- 关注
原创 Swap Nodes in Pairs
public class Solution { public ListNode swapPairs(ListNode head) { ListNode p = head; ListNode q = head; if(head == null){ return head; }else if(head.ne
2014-04-30 19:21:43 464
原创 Same Tree
/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution { publi
2014-04-29 20:32:16 588
原创 Maximum Depth of Binary Tree
/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution { publi
2014-04-29 19:21:39 3429
原创 Palindrome Number
public class Solution { public boolean isPalindrome(int x) { if(x < 0){ return false; } if(x < 10 ){ return true; } String xstr = String.valueOf(x); //System.out.println(xstr
2014-04-28 20:38:52 520
原创 Merge Two Sorted Lists
public class Solution { public ListNode mergeTwoLists(ListNode l1, ListNode l2) { ListNode s1 , s2; if(l1 == null && l2 != null){ return l2; }else if(l1 != null && l2 == null){ r
2014-04-28 20:03:29 488
原创 Climbing Stairs
public class Solution { public int climbStairs(int n) { int res = n - 1; if(n == 0){ return 0; } int[] mem = new int[n]; if(n <= 1){
2014-04-25 20:17:53 1002
原创 Path Sum
/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution { publi
2014-04-25 19:47:40 459
原创 Pascal's Triangle II
public class Solution { public ArrayList getRow(int k) { if(k < 0){ k = 0; } k++; ArrayList> result = new ArrayList>(); for (int i = 0; i < k;
2014-04-25 19:23:24 509
原创 Pascal's Triangle
public class Solution { public ArrayList> generate(int k) { ArrayList> result = new ArrayList>(); for (int i = 0; i < k; i++) { ArrayList tmpResult = new ArrayL
2014-04-25 19:15:05 515
原创 Best Time to Buy and Sell Stock
public class Solution { public int maxProfit(int[] A) { int maxProfit = 0; if(A.length <= 1){ return 0; } int low = A[0]; for (int i = 1; i < A
2014-04-25 17:45:49 528
原创 Best Time to Buy and Sell Stock II
public class Solution { public int maxProfit(int[] A) { int maxProfit = 0; if(A.length < 2){ return 0; } int low = A[0];
2014-04-25 17:42:47 479
原创 Sort Colors
public class Solution { public void sortColors(int[] A) { int countRed = 0; int countBlue = 0; int countBlack = 0; for(int i = 0 ;i < A.length ;i++){ sw
2014-04-25 16:21:32 455
原创 Single Number
public class Solution { public int singleNumber(int[] A) { Map tmpMap = new HashMap(); for(int i = 0 ; i < A.length ; i++){ if(tmpMap.get(A[i]) == null)
2014-04-22 20:49:45 460
原创 Search Insert Position
public class Solution { public int searchInsert(int[] A, int target) { int index = A.length; if(A.length == 1){ if(target <= A[0]) return 0;
2014-04-22 19:56:46 444
原创 Two Sum
public class Solution { public int[] twoSum(int[] values, int target) { Map<Integer , Integer[]> map = new HashMap<Integer , Integer[]>(); for(int i = 0 ; i < valu...
2014-04-22 19:56:04 407
原创 深入浅出Struts2
1 简介 Struts2中的Action都是POJO,这一方面增强了Action本身的可测试性,另一方面也减小了框架内部的耦合度,而HTML表单中的输入项都被转换成了恰当的类型以供action使用。开发人员还可以通过拦截器(可以自定义拦截器或者使用Struts2提供的拦截器)来对请求进行预处理和后处理,这样一来,处理请求就变得更加模块化,从而进一步减小耦合度。模块化是一个通用的主题——可以通过插
2014-04-22 19:54:57 14045
原创 Remove Element
public class Solution { public int removeElement(int[] A, int elem) { int length = A.length; if(length == 0){ return 0; }else{
2014-04-22 19:54:00 3466
原创 Bulk Insert Sample
create table userName( name nvarchar(50), id numeric(9,0) IDENTITY(1,1) not null, CONSTRAINT [PK_userName] PRIMARY KEY (id)) BULK INSERT [logSystem]..[userName] FROM 'D:\BulkInsertTest\bulktest1.txt
2014-04-03 11:00:01 612
转载 Bulk INsert
CREATE TABLE userinfo1(id INT identity,userName varchar(20), pass varchar(20),address varchar(100),phone varchar(20), email varchar(128),registerTime dateti
2014-04-02 21:04:11 431
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人