原创 leetcode 88. Merge Sorted Array

題目 Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: You may assu

原创 leetcode 223. Rectangle Area

題目 Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined by its bottom

原创 leetcode 13. Roman to Integer

題目 Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 解 class

原创 leetcode 371. Sum of Two Integers

題目 Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example: Given a =

原创 劍指offer-面試題25:二叉樹中和爲某一值的路徑

題目 輸入一棵二叉樹和一個整數,打印出二叉樹中結點值的和爲輸入整數的所有路徑。從樹的根結點開始往下一直到葉結點所經過的結點形成一條路徑。二叉樹的定義如下: class TreeNode { int val; TreeNod

原创 劍指offer-面試題18:樹的子結構

題目 輸入兩棵二叉樹A和B,判斷B是不是A的子結構。二叉樹結點的定義如下: public class TreeNode { int val; TreeNode left; TreeNode right; T

原创 leetcode 9. Palindrome Number

題目 Determine whether an integer is a palindrome. Do this without extra space. 解 class Solution { public boolean isP

原创 leetcode 7.Reverse Integer

題目 Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input:

原创 leetcode 1.Two Sum

題目 Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may as

原创 leetcode 461. Hamming Distance

題目 The Hamming distance between two integers is the number of positions at which the corresponding bits are different.

原创 劍指offer-面試題21:包含min函數的棧

題目 定義棧的數據結構,請在該類型中實現一個能夠得到棧的最小元素的min函數。在該棧中,調用min,push及pop的時間複雜度都是O(1)。 解 import java.util.Stack; public class StackWi

原创 劍指offer-面試題24:二叉搜索樹的後序遍歷序列

題目 輸入一個整數數組,判斷該數組是不是某二叉搜索樹的後序遍歷的結果。如果是則返回true,否則返回false。假設輸入的數組的任意兩個數組都互不相同。 解 package Chapter4; public class VertifyS

原创 leetcode 235. Lowest Common Ancestor of a Binary Search Tree

題目 Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to

原创 劍指offer-面試題22:棧的壓入,彈出序列

題目 輸入兩個整數序列,第一個序列表示棧的壓入順序,請判斷第二個序列是否爲該棧的彈出順序。假設壓入棧的所有數字均不相等。例如序列1,2,3,4,5是某棧的壓入序列,序列4,5,3,2,1是該壓棧序列對應的一個彈出序列,但4,3,5,1,2

原创 一個簡單的Hibernate的示例

一.框架圖 二.步驟 1.建立數據庫javaweb(使用的是MySQL數據庫); 2./WebRoot/WEB-INF/lib下添加個Hibernate必須的jar包; 下載地址:http://download.csdn.net/d