原创 java:equals與hascode( )

Java中的equals方法和hashcode方法是Object中的,所以每個對象都是有這兩個方法的,有時候我們需要實現特定需求,可能要重寫這兩個方法。 1.區別 eqauls()和hashcode()方法是用來在同一類中做比較用

原创 二叉樹的遍歷

二叉樹的定義 public class TreeNode { int val; TreeNode left; TreeNode right; TreeNode(int x) { val = x; }

原创 leetcode 219. Contains Duplicate II

題目 Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the arra

原创 leetcode 160. Intersection of Two Linked Lists

原文鏈接:http://blog.csdn.net/litoupu/article/details/41555557 題目 Write a program to find the node at which the interse

原创 劍指offer-面試題8:旋轉數組中的最小數字

題目 把一個數組最開始的若干個元素搬到數組的末尾,我們稱之爲數組的旋轉。輸入一個遞增排序的數組的一個旋轉,輸出旋轉數組的最小元素。例如數組{3,4,5,1,2}爲{1,2,3,4,5}的一個旋轉,該數組的最小元素爲1. 解 pub

原创 leetcode 26. Remove Duplicates from Sorted Array

題目 Given a sorted array, remove the duplicates in place such that each element appear only once and return the new

原创 HTTP 狀態碼

HTTP狀態碼(HTTP Status Code)是用以表示網頁服務器HTTP響應狀態的3位數字代碼。它由RFC 2616規範定義的,並得到RFC 2518,RFC 2295,RFC 2774 ,RFC 4918等規範擴展。 簡單

原创 leetcode 172. Factorial Trailing Zeroes

題目 Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic tim

原创 leetcode 299. Bulls and Cows

題目 guess, you provide a hint that indicates how many digits in said guess match your secret number exactly in both

原创 leetcode 66. Plus One

題目 Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored suc

原创 leetcode 27. Remove Element

題目 Given an array and a value, remove all instances of that value in place and return the new length. Do not alloca

原创 leetcode 205. Isomorphic Strings

題目 Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s c

原创 Java:棧(Stack)和隊列(Queue)的使用

Stack 1基本方法 1–>public Stack() 創建一個空堆棧 2–>public boolean empty() 測試堆棧是否爲空; 3–>public E pop() 移除堆棧頂部的對象,並作爲此函數的值返回該對

原创 劍指offer-面試題6:重建二叉樹

題目 輸入某二叉樹的前序遍歷和中序遍歷的結果,請重建出該二叉樹。假設輸入的前序遍歷和中序遍歷的結果中都不含重複的數字。 解 public static TreeNode buildTree(int[] preOrder,

原创 leetcode 232. Implement Queue using Stacks

題目 Implement the following operations of a queue using stacks. push(x) – Push element x to the back of queue. pop(