原创 leetcode 415. Add Strings字符串加和(C++和Java)

問題描述:   Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. Note:

原创 leetcode 459. Repeated Substring Pattern(重複子字符串)

問題描述:   Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple

原创 leetcode 191. Number of 1 Bits(1的個數)(C++和Java)(無符號位)

問題描述:   Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as th

原创 leetcode 257. Binary Tree Paths(DFS)

問題描述:   Given a binary tree, return all root-to-leaf paths.   For example, given the following binary tree: 代碼:

原创 leetcode 101. Symmetric Tree對稱樹(遞歸和迭代)

問題描述:   Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). 遞歸: /**

原创 leetcode 70. Climbing Stairs爬梯子(DP問題)

問題描述:   You are climbing a stair case. It takes n steps to reach to the top.   Each time you can either climb 1 or

原创 leetcode 438. Find All Anagrams in a String在字符串中尋找同構體(Sliding Window)

問題描述:   Given a string s and a non-empty string p, find all the start indices of p’s anagrams in s.   Strings consi

原创 leetcode 326. Power of Three(3的次方)

問題描述:   Given an integer, write a function to determine if it is a power of three. Follow up:   Could you do it wit

原创 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.   Ac

原创 leetcode 198. House Robber(DP問題)

問題描述:   You are a professional robber planning to rob houses along a street. Each house has a certain amount of mon

原创 leetcode 405. Convert a Number to Hexadecimal(十進制轉十六進制>>>)

問題描述:   Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two’s complement m

原创 Java類初始化的順序

  我們大家都知道,對於靜態變量、靜態初始化塊、變量、初始化塊、構造器,它們的初始化順序依次是(靜態變量、靜態初始化塊)>(變量、初始化塊)>構造器。我們也可以通過下面的測試代碼來驗證這一點: public class Initi

原创 leetcode 437. Path Sum III(路徑和)(DFS)

問題描述:   You are given a binary tree in which each node contains an integer value.   Find the number of paths that s

原创 leetcode 172. Factorial Trailing Zeroes(階乘尾後0個數)(因式分解)

問題描述:   Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmi

原创 深入理解Java的接口和抽象類

  對於面向對象編程來說,抽象是它的一大特徵之一。在Java中,可以通過兩種形式來體現OOP的抽象:接口和抽象類。這兩者有太多相似的地方,又有太多不同的地方。很多人在初學的時候會以爲它們可以隨意互換使用,但是實際則不然。今天我們就